我想做一个这样的菜单:
以及到目前为止我所做的:
<nav class="container site-navigation clearfix">
<ul id="menu-main-menu" class="main-menu">
<li id="menu-item-7" class="current-menu-item current_page_item">
<a href="http://localhost/artech/">Home</a>
</li>
<li id="menu-item-50" class="menu-item menu-parent-item">
<a href="http://localhost/artech/teaching/">Teaching</a>
<div class="sub-menu-outer">
<div class="sub-menu-inner">
<ul class="sub-menu">
<li id="menu-item-75" class="menu-item">
<a href="http://localhost/artech/teaching/description/">Description</a>
</li>
<li id="menu-item-84" class="menu-item">
<a href="http://localhost/artech/teaching/papers/">Papers</a>
</li>
<li id="menu-item-82" class="menu-item">
<a href="http://localhost/artech/teaching/tasks/">Tasks</a>
</li>
<li id="menu-item-83" class="menu-item">
<a href="http://localhost/artech/teaching/log-in/">Log In
</a>
</li>
</ul>
</div>
</div>
</li>
<li id="menu-item-21" class="menu-item">
<a href="http://localhost/artech/creative-technology/">Creative Technology</a>
</li>
<li id="menu-item-20" class="menu-item">
<a href="http://localhost/artech/blog/">Blog</a></li>
<li id="menu-item-19" class="menu-item"><a href="http://localhost/artech/bio/">Bio</a>
</li>
<li id="menu-item-18" class="menu-item">
<a href="http://localhost/artech/contact/">Contact</a>
</li>
</ul>
</nav>
和CSS:
ul{list-style: none; padding: 0; margin: 0;}
nav{
background: url(http://img29.imageshack.us/img29/3563/6s9a.png) repeat-x bottom left;
height: 44px;
}
#menu-main-menu > li{position: relative; float:left;}
#menu-main-menu > li:not(:first-child){
margin-left: 70px;
}
#menu-main-menu li a{color: #000000; line-height: 35px;}
#menu-main-menu .current-menu-item a,#menu-main-menu .current_page_item a, #menu-main-menu > li:hover a{
font-weight: 700;
}
#menu-main-menu > li:hover ul.sub-menu li a{
font-weight: 400;
}
#menu-main-menu > li:hover ul.sub-menu li:hover a{
font-weight: 700;
}
.sub-menu-outer{background: url(http://img12.imageshack.us/img12/5050/3g1y.png) repeat-y top right #FFFFFF;
} /* two line stripe y*/
.sub-menu-inner{
background: url(http://img12.imageshack.us/img12/5050/3g1y.png) repeat-y top left;
} /* two line stripe y*/
.sub-menu{
background: url(http://img29.imageshack.us/img29/3563/6s9a.png) repeat-x bottom left;
} /* one line stripe x*/
.sub-menu > li{
padding: 5px 15px;
text-align: center;
}
#menu-main-menu > li.menu-parent-item .sub-menu-outer {
display: none;
float: left;
position: absolute;
left: 0;
top: 0;
margin-top: 35px;
}
#menu-main-menu > li.menu-parent-item:hover > .sub-menu-outer{
display: block;
z-index: 1000;
}
我有以下无法解决我自己的问题:
- 左右 y 条纹必须从父 li 的乞求开始,并在子菜单的末尾结束,而不覆盖(我有白色背景)父的 li 单词/页面链接。
- 如图所示,子菜单底部的 x 条纹必须在左右条纹上方
- 子菜单必须以父级的宽度为中心
是否可以仅使用 css 解决所有这些问题,或者我必须使用 jquery。我尝试了很多,尤其是在职位上,但无法达到预期的效果。
任何帮助都非常感谢。