gpt4 book ai didi

html - 我如何将此下拉菜单实际设置为 "drop down"

转载 作者:太空宇宙 更新时间:2023-11-04 13:50:42 25 4
gpt4 key购买 nike

我制作的这个导航栏在某些按钮上有下拉菜单。我想这样做,当激活下拉菜单的按钮悬停在上方时,下拉菜单会像这样下降到位:http://designmodo.com/demo/css3dropdownmenu/

这是我的代码的链接:http://jsfiddle.net/w5Ce7/2/

这里是刚刚粘贴的代码:

HTML

<div id="container">
<div id="navbar">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Questions</a></li>
<li><a href="#">Classes</a></li>
<li><a href="#">Designer</a></li>
<li><a href="#">Flavors</a></li>
<li><a href="#">Cakes</a>
<ul>
<li ><a href="#">Budget Cakes</a></li>
<li><a href="#">Wedding</a>
<ul>
<li><a href="#">Wedding 1</a></li>
<li><a href="#">Wedding 2</a></li>
<li><a href="#">Wedding 3</a></li>
<li><a href="#">Wedding 4</a></li>
<li><a href="#">Wedding 5</a></li>
<li><a href="#">Wedding 6</a></li>
</ul>
</li>
<li ><a href="#">Cakes to Go</a></li>
<li ><a href="#">Cake Bonbons</a></li>
<li ><a href="#">Holiday Cakes</a></li>
<li ><a href="#">Cakes for Girls</a></li>
<li ><a href="#">Cakes for Boys</a></li>
<li ><a href="#">For Her</a></li>
<li ><a href="#">For Him</a></li>
<li ><a href="#">Cupcakes</a></li>
</ul>
</li>
<li><a href="#">Events</a>
<ul>
<li><a href="#">Beach Wedding</a></li>
<li><a href="#">Baby Showers</a></li>
<li><a href="#">Sweet 15-16</a></li>
</ul>
</li>
</ul>
</div><!--end of navbar-->

CSS

body {
margin:0;
font-family:Georgia, Arial black, Times, serif;
}


h2 {
text-align:center;
}

img {
border:none;
border:0;
}


#topbanner {
width:100%;
height:40px;
background-color:#88C6CC;
color:#fff;
text-align:center;
line-height:40px;
font-size:36px;
}


#container {
width:1050px;
height:800px;
background-color:#B7E6E8;
margin:auto;
position:relative;
border-radius:20px;
-moz-border-radius:20px;
-webkit-border-radius:20px;
-ms-border-radius:20px;
-o-border-radius:20px;
margin-top:10px;
}



/*Start Navigation Bar*/
#navbar ul ul {
display:none;
}

#navbar ul li:hover > ul {
display:block;
}

#navbar ul {
background: #efefef;
background: linear-gradient(top, #efefef 0%, #bbbbbb 100%);
background: moz-linear-gradient(top, #efefef 0%, #bbbbbb 100%);
background: webkit-linear-gradient(top, #efefef 0%, #bbbbbb 100%);
box-shadow: 0px 0px 9px rgba(0,0,0,0.15);
padding: 0 40px;
border-radius:10px;
-moz-border-radius:10px;
-webkit-border-radius:10px;
list-style:none;
position:relative;
display:inline-table;
}



#navbar ul:after {
content: ""; clear: both; display: block;
}

#navbar ul li {
float:left;
-webkit-transition:background 0.3s ease-in;
-moz-transition:background 0.3s ease-in;
-o-transition:background 0.3s ease-in;
-ms-transition:background 0.3s ease-in;
transition:background 0.3s ease-in;
}

#navbar ul li:hover {
background:#4b545f;
}


#navbar ul li:hover a {
color:#fff;
}

#navbar ul li a {
display:block;
padding:25px 40px;
color:#757575;
text-decoration:none;
}

#navbar ul ul {
background: #5f6975;
border-radius:0px;
-webkit-border-radius:0px;
-moz-border-radius:0px;
padding: 0;
position:absolute;
top:100%;
width:195px;
z-index:1;
}

#navbar ul ul li {
float:none;
border-top:1px solid #6b727c;
border-bottom: 1px solid #575f6a;
position:relative;
}

#navbar ul ul li a {
padding: 15px 40px;
color:#fff;
}

#navbar ul ul li a:hover {
background: #4b545f;
}

#navbar {
text-align:center;

}

#navbar ul ul ul {
position:absolute;
left:100%;
top:0;
width:155px;
}

最佳答案

给你。 <强> FIDDLE 。问题是将子 ul 显示为 block 。

#navbar ul li:hover > ul {
opacity:1;
height:auto !Important;
}
#navbar ul li:hover > ul > li {
height:50px !important;
opacity:1;
}
#navbar ul {
background: #efefef;
background: linear-gradient(top, #efefef 0%, #bbbbbb 100%);
background: moz-linear-gradient(top, #efefef 0%, #bbbbbb 100%);
background: webkit-linear-gradient(top, #efefef 0%, #bbbbbb 100%);
box-shadow: 0px 0px 9px rgba(0, 0, 0, 0.15);
padding: 0 40px;
border-radius:10px;
-moz-border-radius:10px;
-webkit-border-radius:10px;
list-style:none;
position:relative;
display:inline-table;
}
#navbar ul:after {
content:"";
clear: both;
display: block;
}
#navbar ul li {
float:left;
-webkit-transition:background 0.3s ease-in;
-moz-transition:background 0.3s ease-in;
-o-transition:background 0.3s ease-in;
-ms-transition:background 0.3s ease-in;
transition:background 0.3s ease-in;
position:relative;
}
#navbar ul li:hover {
background:#4b545f;
}
#navbar ul li:hover a {
color:#fff;
}
#navbar ul li a {
display:block;
padding:25px 40px;
color:#757575;
text-decoration:none;
}
#navbar ul ul {
background: #5f6975;
border-radius:0px;
-webkit-border-radius:0px;
-moz-border-radius:0px;
padding: 0;
position:absolute;
top:100%;
left:0px;
width:195px;
z-index:1;
-webkit-transition:all 0.4s ease-in-out;
transition:all 0.4s ease-in-out;
opacity:0;
height:0px;
}
#navbar ul ul li {
float:none;
border-top:1px solid #6b727c;
border-bottom: 1px solid #575f6a;
position:relative;
height:0px;
-webkit-transition:all 0.4s ease-in-out;
transition:all 0.4s ease-in-out;
opacity:0;
}
#navbar ul ul li a {
padding: 15px 40px;
color:#fff;
}
#navbar ul ul li a:hover {
background: #4b545f;
}
#navbar {
text-align:center;
}
#navbar ul ul ul {
position:absolute;
left:100%;
top:0;
width:155px;
}

关于html - 我如何将此下拉菜单实际设置为 "drop down",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22236395/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com