2014-09-19 45 views
0

我正在尝试为朋友建立一个网站,我正在使用Drupal 7构建它。 我有一个令我发疯的CSS问题。我漂浮在右边的二级菜单不在我的内容旁边。相反,它显示在我的内容下方。中级菜单在Drupal 7中无法正确显示

我觉得我已经尝试了一切。我有第一个菜单左浮动,二级浮动右,和边缘上的内容自动左和右。

我也尝试清除底层容器,但它也没有帮助。 我在Firefox和Chrome中遇到此错误。

我可以在网上找到的唯一的解决方案,我还没有尝试过,是漂浮左前浮动,因为我必须修补Drupal核心。

我之前实际上遇到过这个问题,并且重建了整个该死的网站,并且在试图将我的组件集中时再次发生。

自从按'撤消'后,我改变了太多,所以如果有很多CSS知识的人可以解释为什么会出现这种情况,那将会很棒。

如果你想看到的问题,就这一页www.mohaaleague.com,在右下角,但它应该是一样高的左侧菜单....

.two-sidebars #content /*the middle element*/ 
{ 
    width: 827px; 
    margin-left:auto; 
    margin-right:auto; 
} 

#sidebar-second /*the right sidebar*/ 
{ 
    width: 287px; 
    float:right; 
} 

#sidebar-first /*the left sidebar*/ 
{ 
    float:left; 
    width: 287px; 
} 

#main /*the underlying div that holds all the others*/ 
{ 
    width: 1650px; 
    margin-left: auto; 
    margin-right: auto; 
    position: relative; 
    clear: both; 
} 
+0

您需要发布的HTML和CSS的相关元素。通常情况下,当您没有为每个项目定义宽度或者当您的边距+宽度超过父容器时会发生这种情况。顺便说一句,这几乎肯定不是一个drupal问题。虽然drupal确实吐出了几乎任何cms的最不必要的复杂标记,但它仍然遵循与其他系统相同的css规则 – 2014-09-19 22:40:13

+0

@Kai Qinq我添加了CSS,我不知道在哪里可以找到HTML因为它在Drupal的模板中,我没有触及过 – 2014-09-19 23:02:44

+0

你可以右键单击,检查元素并将其复制为2个元素的整个父元素的html。对于大多数人来说可能是一个充满眼光的人,所以我只是看看CSS,看看有没有什么突出的 – 2014-09-19 23:22:23

回答

0

顺便说一句我从BARTIK主题开始。

好的,所以我设法通过改变page.tpl.php来解决它,这实际上是我在我的问题中提出的。

问题是float float在离开之前被调用。所以我改变了Drupal渲染页面的顺序。通过让Drupal首先渲染我的第二个边栏,然后渲染我的第一边栏,然后我解决了这个问题。

我在主题改变page.tpl.php中Templates目录尚且如此,如果你正在读这篇文章,有同样的问题更改代码的顺序是:

 <?php if ($page['sidebar_second']): ?> 
    <div id="sidebar-second" class="column sidebar"><div class="section"> 
    <?php print render($page['sidebar_second']); ?> 
    </div></div> <!-- /.section, /#sidebar-second --> 
<?php endif; ?> 

<?php if ($page['sidebar_first']): ?> 
    <div id="sidebar-first" class="column sidebar"><div class="section"> 
    <?php print render($page['sidebar_first']); ?> 
    </div></div> <!-- /.section, /#sidebar-first --> 
<?php endif; ?> 

<div id="content" class="column"><div class="section"> 
    <?php if ($page['highlighted']): ?><div id="highlighted"><?php print render($page['highlighted']); ?></div><?php endif; ?> 
    <a id="main-content"></a> 
    <?php print render($title_prefix); ?> 
    <?php if ($title): ?> 
    <h1 class="title" id="page-title"> 
     <?php print $title; ?> 
    </h1> 
    <?php endif; ?> 
    <?php print render($title_suffix); ?> 
    <?php if ($tabs): ?> 
    <div class="tabs"> 
     <?php print render($tabs); ?> 
    </div> 
    <?php endif; ?> 
    <?php print render($page['help']); ?> 
    <?php if ($action_links): ?> 
    <ul class="action-links"> 
     <?php print render($action_links); ?> 
    </ul> 
    <?php endif; ?> 
    <?php print render($page['content']); ?> 
    <?php print $feed_icons; ?>