下拉导航 - 两层菜单 (CSS/HTML)
我一直在研究如何制作双下拉菜单。
我正在使用的实时页面:http://www.glustik.com/dustreeproducts/
“<强>娱乐”按钮,将是唯一一个带有下拉菜单的按钮。 我已经设置了父选择,但是当鼠标悬停在父选择上时,每个选择都会有一小部分乐队列表。
示例:“舞蹈”将有大约 7 个乐队(乐队#1 - 乐队#7) 辅助下拉菜单应显示在父下拉菜单的右侧。
任何帮助将不胜感激。我已经为此苦苦挣扎了一段时间。
我的相关 HTML(导航)标记:
<div id="main-nav">
<div id="nav">
<ul>
<li id="company"><a title="Company" href="http://www.glustik.com/dustreeproductions/company.php"></a></li>
<li id="entertainment"><a title="Entertainment" href="http://www.glustik.com/dustreeproductions/entertainment.php"></a>
<ul id="sub">
<li id="dance"> <a href="http://www.jasontanzer.com/guitarist-original-music.asp">Dance</a></li>
<li id="classicRock"><a href="http://www.jasontanzer.com/guitarist-shows-covers.asp">Classic Rock | Top 40 | Rock</a></li>
<li id="country"><a href="http://www.jasontanzer.com/commercial-tv-film-jingles.asp">Country</a></li>
<li id="rockabilly"><a href="http://www.jasontanzer.com/composer.asp">Rockabilly | Reggae | Bluegrass | Other</a></li>
. . . . . and so on.
我的 CSS(导航)标记:
#nav #company a {
background:url(../images/navigation/nav-company.png) no-repeat;
display:block;
text-decoration:none;
width:103px;
margin:20px 27px 0 20px;
height:20px;}
#nav #company:hover > a {
background-position:0 -20px;}
#nav #company a:active {
background-position:0 -40px;}
body#body_company #company a {
background-position:0 -40px;}
#nav #entertainment a {
background:url(../images/navigation/nav-entertainment.png) no-repeat;
display:block;
text-decoration:none;
width:168px;
margin:20px 27px 0 0;
height:20px;}
#nav #entertainment:hover > a {
background-position:0 -20px;}
#nav #entertainment a:active {
background-position:0 -40px;}
body#body_entertainment #entertainment a {
background-position:0 -40px;}
. . . . . and so on.
I have been working on figuring out how to make a double drop down menu.
Live Page I am working with : http://www.glustik.com/dustreeproductions/
The "Entertainment" button, will be the only one with a Drop Down.
I have set up the parent selection, but each one will have a small list of bands when hovered over.
Example: "Dance" will have about 7 bands (Band #1 - Band#7)
The secondary drop down should appear to the right of the parent drop down menu.
Any help would be greatly appreciated. I have been struggling with this for some time.
My Relavant HTML (nav) Markup :
<div id="main-nav">
<div id="nav">
<ul>
<li id="company"><a title="Company" href="http://www.glustik.com/dustreeproductions/company.php"></a></li>
<li id="entertainment"><a title="Entertainment" href="http://www.glustik.com/dustreeproductions/entertainment.php"></a>
<ul id="sub">
<li id="dance"> <a href="http://www.jasontanzer.com/guitarist-original-music.asp">Dance</a></li>
<li id="classicRock"><a href="http://www.jasontanzer.com/guitarist-shows-covers.asp">Classic Rock | Top 40 | Rock</a></li>
<li id="country"><a href="http://www.jasontanzer.com/commercial-tv-film-jingles.asp">Country</a></li>
<li id="rockabilly"><a href="http://www.jasontanzer.com/composer.asp">Rockabilly | Reggae | Bluegrass | Other</a></li>
. . . . . and so on.
My CSS (nav) Markup :
#nav #company a {
background:url(../images/navigation/nav-company.png) no-repeat;
display:block;
text-decoration:none;
width:103px;
margin:20px 27px 0 20px;
height:20px;}
#nav #company:hover > a {
background-position:0 -20px;}
#nav #company a:active {
background-position:0 -40px;}
body#body_company #company a {
background-position:0 -40px;}
#nav #entertainment a {
background:url(../images/navigation/nav-entertainment.png) no-repeat;
display:block;
text-decoration:none;
width:168px;
margin:20px 27px 0 0;
height:20px;}
#nav #entertainment:hover > a {
background-position:0 -20px;}
#nav #entertainment a:active {
background-position:0 -40px;}
body#body_entertainment #entertainment a {
background-position:0 -40px;}
. . . . . and so on.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于您的 CSS 已经包含 子组合器 选择器,我假设您不关心不支持它的浏览器(如 IE6)。
只需 CSS 即可完成。我将文本添加到
元素中以供显示,并将 Band #1 - Band#7 添加到 Dance 和 Band #1 - Band#7 和 Band #1 - Band#7 >乐队#1到下一个项目只是为了显示与顶级音乐流派的对齐。
希望这有帮助:-)
Since your CSS already contains the child combinator selector, I am assuming you don't care for browsers that don't support it (like IE6).
It can be done with just CSS. I added the text to the
<a>
elements for display purposes and added Band #1 - Band#7 to Dance and a Band #1 to the next item just to show the alignment with the top of the music genre.Hope this helps :-)