css导航栏:子子菜单仅重叠IE中的主菜单

时间:2012-08-21 06:43:46

标签: css internet-explorer navigationbar

以下导航栏适用于firefox,IE和Chrome。但是,在IE上,单击子菜单时显示的子子菜单未正确定位。它似乎与主菜单重叠。

我可以在不影响其他浏览器的导航栏布局的情况下为IE正确定位吗?问题出在navbar.css代码的最后一行。保证金顶部:-23px适用于除IE以外的所有浏览器。我在悬停时面临问题:

  1. 新闻和活动(运动日LInk和年日链接重叠常见问题解答(主菜单项)
  2. 招生(立即注册链接重叠招生链接本身)
  3. 顺便说一句,我正在测试IE9。

    谢谢。

    navbar.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-->
    

1 个答案:

答案 0 :(得分: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;}