[英]HTMl CSS Dropdown Nav
I have a navigation menu that works well and looks good. 我有一个导航菜单,效果很好,看起来也不错。
The HTML for the menu is: 菜单的HTML是:
<div id="menubar">
<div id="welcome">
<h1><a href="#">Cedars Hair <span>Academy</span></a></h1>
</div><!--close welcome-->
<div id="menu_items">
<ul id="menu">
<li class="current"><a href="index.html">Home</a></li>
<li><a href="index.html">The Salon</a></li>
<li><a href="index.html">Testimonials</a></li>
<li><a href="index.html">Courses</a></li>
<li><a href="index.html">The Staff</a></li>
<li><a href="index.html">Contact Us</a></li>
</ul>
</div><!--close menu-->
</div><!--close menubar-->
But I want to change it so it is something like: 但我想更改它,所以它类似于:
<li><a href="#">The Salon</a>
<ul>
<li><a href="#">Hair Cut</a></li>
</ul>
</li>
So under the salon, a drop down menu would come up with 'Hair Cut'. 因此,在沙龙下,下拉菜单将带有“ Hair Cut”。
I know this is possible with CSS, but the problem is I have a lot of CSS with the divs shown above (menubar, welcome, menu_items etc). 我知道CSS可以做到这一点,但是问题是我有很多CSS,上面显示了div(菜单,欢迎,menu_items等)。 Do you know the most simplest way to make a simple dropdown? 您知道最简单的下拉菜单最简单的方法吗?
The simplest way in a nutshell: 简而言之,最简单的方法是:
https://jsfiddle.net/svArtist/2jd9uvx0/ https://jsfiddle.net/svArtist/2jd9uvx0/
hide lists inside other lists 隐藏其他列表中的列表
upon hovering list elements, show the child lists 悬停列表元素后,显示子列表
ul ul { display:none; display:absolute; bottom:-100%; } li{ position:relative; } li:hover>ul { display:table; }
<ul> <li><a href="#">The Salon</a> <ul> <li><a href="#">Hair Cut</a> </li> </ul> </li> </ul>
Why don't you use Jquery UI? 为什么不使用Jquery UI? https://jqueryui.com/menu/ https://jqueryui.com/menu/
<script>
$(function() {
$( "#menu" ).menu();
});
</script>
Added the sub menu using li:hover
使用li:hover
添加了子菜单
Here is the fiddle - https://jsfiddle.net/gkdj6y5x/ 这是小提琴-https: //jsfiddle.net/gkdj6y5x/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.