我目前正在使用position:absolute;对于第二级菜单,因为当我使用position:relative;第一级菜单被打破(在悬停的项目是换行符之后?)
但是我希望实现所显示的第二级菜单相对于第一级菜单中的悬停项目(直接位于其下方并且也是水平位置)
我的菜单目前是这样的:
Home / Test / News
Test_Sub1 / Test_Sub2 / Test_Sub3
但应该是
Home / Test / News
Test_Sub1 / Test_Sub2 / Test_Sub3
这是我的CSS代码
#navigation ul.menu {
list-style-type:none;
list-style:none;
/*overflow:hidden;*/
width:980px;
}
#navigation li {
list-style:none;
list-style-type:none;
padding:0;
float:left;
display:inline;
height:32px;
}
#navigation ul.menu {
width:100%;
height:32px;
border-bottom: 1px solid #cecbcd;
}
/* style list as navigation using float:left */
/* set distance from left corner to the first li item */
#navigation ul.menu li:first-child {
margin-left:150px;
}
#navigation ul.menu li ul li:first-child {
margin-left:0px;
}
#navigation ul.menu li ul {display:none; position:absolute; top:32px; left: 10em; float:left; border:none;}
#navigation ul.menu li:hover ul {display:inline;}
#navigation ul.menu li:hover ul li {height:45; padding-top:8px; float:left; position: relative;}
#navigation ul.menu li:hover ul li a {float:left;}
#navigation ul.menu li ul li {display:inline; background-image:none; float:left; position:relative; left: 5em; }
#navigation ul.menu li a {
/*background-color:#ffffff; */
font: 12pt/24pt 'SansumiRegular', Arial, sans-serif;
text-decoration:none;
color: #666666;
height: 32px;
background-image:none;
display:block;
padding-left:5px;
padding-right:5px;
float: left;
}
#navigation ul.menu li ul li a {
/*background-color:#ffffff; */
font: 12pt/24pt 'SansumiRegular', Arial, sans-serif;
text-decoration:none;
color: #666666;
height: 32px;
background-image:none;
display:block;
padding-left:5px;
padding-right:5px;
float: left;
}
#navigation ul.menu li ul li a:hover, #navigation ul.menu li ul li.active-trail a.active-trail {
/*background-color:#ffffff; */
font: 12pt/24pt 'SansumiRegular', Arial, sans-serif;
text-decoration:underline;
color: #666666;
height: 32px;
background-image:none;
display:block;
padding-left:5px;
padding-right:5px;
float: left;
}
#navigation ul.menu li a:hover {
font: 12pt/24pt 'SansumiRegular', Arial, sans-serif;
text-decoration:none;
color: #ffffff;
height: 32px;
background-image:url('../images/navi_active.png');
background-position:center;
background-repeat:no-repeat;
}
#navigation ul.menu li a.active, #navigation ul.menu li.active-trail a.active-trail {
font: 12pt/24pt 'SansumiRegular', Arial, sans-serif;
text-decoration:none;
color: #ffffff;
height: 32px;
background-image:url('../images/navi_active.png');
background-position:center;
background-repeat:no-repeat;
}
div.region-header ul.menu {
display:none;
}
答案 0 :(得分:1)
试试这个:http://jsfiddle.net/rathoreahsan/3NRu4/
编辑:
我找到了你的代码:
你定义了:
#navigation ul.menu li:hover ul {display:inline;}
将其改为:
#navigation ul.menu li:hover ul {display:block;}
同样在这一行,
#navigation ul.menu li ul li {display:inline; background-image:none; float:left; position:relative; left: 5em; }
删除left: 5em
以获得如下结果:http://jsfiddle.net/rathoreahsan/GFURU/
编辑:
更多关于这一行:
#navigation ul.menu li ul {display:none; position:absolute; top:32px; float:left; border:none; background:red; left: 10em;}
移除left: 10em
以获得ul
相对位置
参见演示:http://jsfiddle.net/rathoreahsan/rTsAE/
希望能解决它。