我正在开发一个Wordpress网站并尝试显示我的菜单,如图所示。如何在选择父菜单时显示子菜单?
答案 0 :(得分:1)
您可以使用二级嵌套创建主要顶部链接,如此
<ul class="primary">
<li>Tutorial</li>
<ul class="secondary">
<li>Photoshop</li>
<li>Illustrator</li>
<li>Flash</li>
<li>HTML</li>
<li>PHP</li>
<li>Wordpress</li>
<li>jQuery</li>
<li>more...</li>
</ul>
<li>Wallpaper</li>
<li>Get A Quote</li>
<li>Photography</li>
<li>Freelance</li>
</ul>
那么你的样式就是这样(这只是使用CSS3,而不是JS)
<style>
ul.primary {
width: -- ;
height: -- ;
margin: -- ;
overflow: hidden;
}
ul.primary > li {
width: -- ;
height: -- ;
margin: -- ;
float: left;
list-style: none;
}
ul.seconday {
opacity: 0;
width: -- ;
height: -- ;
margin: -- ; /* when this is used with position: relative you can adjust where the drop down is placed. */
position: relative; /* need to set this to relative to position properly */
/* css3 transition */
transition: all .5s ease-in;
-webkit-transition: all .5s ease-in;
-moz-transition: all .5s ease-in;
-ms-transition: all .5s ease-in;
-o-transition: all .5s ease-in;
}
ul.primary > li:hover ul.secondary {
opacity: 1;
}
</style>