0

以下导航栏在 Firefox、IE 和 Chrome 上完美运行。但是,在 IE 上,单击子菜单时显示的子子菜单位置不正确。它似乎与主菜单重叠。

如何在不影响其他浏览器导航栏布局的情况下为 IE 正确定位?问题出在 navbar.css 代码的最后一行。Margin-top:-23px 适用于除 IE 以外的所有浏览器。我在悬停时遇到问题:

  1. 新闻和事件(运动会链接和年会链接重叠常见问题解答(主菜单项)
  2. 招生(现在注册链接与招生链接本身重叠)

顺便说一句,我正在测试IE9。

谢谢你。

导航栏.css

#menu {
border:none;
border:0px;
margin:0px;
margin-bottom:5%;
padding:0px;
    /*font: 67.5% "Lucida Sans Unicode", "Bitstream Vera Sans", "Trebuchet Unicode MS", "Lucida Grande", Verdana, Helvetica, sans-serif;*/
    font-size:18px;
    font-weight:bold;
}

#nav {
    height:25px;    /*35px;*/
    list-style-type:none;
    margin:0;
    padding:0;
    float:left;
    text-align:center;
    background:#ffcd05;
        }

#nav li {
    display:inline-block;
    position:relative;
    float:left;
/*    background: #006633;
*/  background:#f26739;

    }

#nav li a {
    display:inline-block;
    width:126px;
    line-height:25px;
    padding:0;
    text-decoration:none;
    color:#ffffff;
    }

#nav li li {float:left; #006633;}

#nav li li a {display:block;font-size:14px;}

#nav li:hover {background:#000000;}

/*--- Sublist Styles ---*/
#nav ul {
    position:absolute;
    padding:0px;
    left:0;
    display:none;
    }

/*--- Hide Sub Sublists ---*/
#nav li:hover ul ul {display:none;}

/*--- Sublevel UL's display and position on hover ---*/
#nav li:hover ul {display:block;} 
#nav li li:hover ul {margin-left:110px; margin-top:-23px; display:block;}

我的导航栏:

<div id="menu">
    <ul id="nav">
<!--        <li><?php echo $this->Html->link('Home', '/pages/home', array()); ?></li>
-->         <li><?php echo $this->Html->link('Our Program', '#', array()); ?><ul>
            <li><?php echo $this->Html->link('Preschool', '/pages/preschool', array()); ?></li>
            <li><?php echo $this->Html->link('Kindergarten', '/pages/kindergarten', array()); ?></li>
            <li><?php echo $this->Html->link('Summer Camp', '/pages/summer_camp', array()); ?></li>
            </ul>
            </li>
            <li><?php echo $this->Html->link('About Us','#', array()); ?><ul>
            <li><?php echo $this->Html->link('Merry Flowers', '/pages/about_us', array()); ?></li>
            <li><?php echo $this->Html->link('Tour Our School','/pages/tour_our_school', array()); ?></li>
            <li><?php echo $this->Html->link('Contact Us', '/pages/contact_us', array()); ?></li>
            </ul>
            </li>

            <li><?php echo $this->Html->link('My Child','#', array()); ?><ul>
            <li><?php echo $this->Html->link('Report Card', '/merry_parents/register', array()); ?></li>
            </ul>
            </li>

            <li><?php echo $this->Html->link('Events','#', array()); ?><ul>
            <li><?php  echo $this->Html->link('News & Events', '#', array()); ?>
                <ul>
                    <li><?php echo $this->Html->link('Sports Day','/pages/sports_day',array()); ?></li>
                    <li><?php echo $this->Html->link('Annual Day','/pages/annual_day',array()); ?></li>
                </ul>
            </li>

            <li><?php  echo $this->Html->link('List of Holidays', '/pages/list_of_holidays', array()); ?></li>
            </ul>
            </li>
            <li><?php echo $this->Html->link('FAQ','#',array()); ?><ul>
            <li><?php  echo $this->Html->link('FAQ', '/pages/faq', array()); ?></li>
            <li><?php  echo $this->Html->link('Feedback', '/feedbacks/add', array()); ?></li>
            <li><?php  echo $this->Html->link('Discussion', '/forum/home', array()); ?></li>
            </ul>
            </li>
            <li><?php echo $this->Html->link('Admissions','#',array()); ?><ul>
            <li><?php echo $this->Html->link('Enroll Now','/students/add', array()); ?></li>
            </ul>
            </li>
        </ul><!--finish ul nav-->
</div> <!--finish div menu-->
4

1 回答 1

0

好的,我让它工作了。一旦我为子列表样式添加了 top:23px,运动日和年日子菜单就不会与新闻和事件重叠。谢谢。

#menu {
padding:0;
margin:0;
border:none;
margin-bottom:5%;


 /*font: 67.5% "Lucida Sans Unicode", "Bitstream Vera Sans", "Trebuchet Unicode MS", "Lucida Grande", Verdana, Helvetica, sans-serif;*/
    font-size:18px;
    font-weight:bold;
    position:relative;
    z-index:1;
}
#nav{
  padding:0;
    margin:0;
    border:none;
  list-style-type:none;
  float:left;
  height:25px;
  text-align:center;
  background:#ffcd05;
}

#nav li{ /*our program, about us, my child, event, etc..*/
     float:left;
     display:block;
     text-align:center;
     background:#f26739;
      width:126px;
      position:relative;  /*very important for good layout of submenus*/
     }
#nav li a{
    text-decoration:none;
    display:block;
    color:#ffffff;
    padding:0;
}
#nav li ul li{font-size:14px;}

#nav li:hover{
      background:#000000;
}
/* sublists style */
#nav ul{  /*lists that come under our program, event, etc...*/
position:absolute; /* very impt for good layout of submenus*/
left:0px;
top:23px;  /*sports day and annual day submenus will not overlap news and events*/
display:none;
padding:0;
}

/*--- Hide Sub Sublists ---*/
#nav li:hover ul ul {display:none;}

/*--- Sublevel UL's display and position on hover ---*/
#nav li:hover ul{display:block;}

#nav li li:hover ul {margin-left:110px; margin-top:-23px;display:block;}
于 2012-08-22T06:59:47.600 回答