我有一个侧栏菜单,有项目回家,画廊,谁是最好的和竞争。
画廊有一个崩溃和扩展下拉,谁是最好的,并且工作正常。在竞争标签中,本周下拉名称榜首,本周的榜单还有5个项目下降。我希望那个像画廊一样,当我参加比赛时本周的顶级名单出现,当我点击本周的顶级名单时,项目出现并且像画廊一样会有扩展和崩溃。
HTML:
<ul id="nav">
<li><a href="index.php"><img src="images/home.png"/> Home</a></li>
<li><a href="#" class="sub" tabindex="1"><img src="images/categories.png"/>Gallery</a><img src="images/up.gif" alt=""/>
<ul>
<li><a href="cars.php"><img src="images/cars.png"/>Cars</a></li>
<li><a href="movies.php"><img src="images/movies.png"/>Movies</a></li>
<li><a href="babies.php"><img src="images/baby.jpg"/>Babies</a></li>
<li><a href="puppies.php"><img src="images/puppies.png"/>Puppies</a></li>
</ul>
</li>
<li><a href="#" class="sub" tabindex="1"><img src="images/best.png"/>Who is the best</a><img src="images/up.gif" alt=""/>
<ul>
<li><a href="#"><img src="images/voteforcars.png"/>Vote for Cars</a></li>
<li><a href="#"><img src="images/voteforsport.png"/>Vote for Sports</a></li>
<li><a href="#"><img src="images/voteformovies.jpg"/>Vote for Movies</a></li>
</ul>
<li><a href="#" class="sub" tabindex="1"><img src="images/toplits.png"/>Competition</a><img src="images/up.gif" alt=""/>
<ul>
<li><a href="#" class="sub" tabindex="1"><img src="images/top.jpg"/>Toplists of Weak</a><img src="images/up.gif" alt=""/>
<ul>
<li><a href="#"><img src="images/sports.png"/>Sports</a></li>
<li><a href="#"><img src="images/cars.png"/>Cars</a></li>
<li><a href="#"><img src="images/movies.png"/>Movies</a></li>
<li><a href="#"><img src="images/images.png"/>Images</a></li>
<li><a href="#"><img src="images/baby.jpg"/>Babies</a></li>
</ul>
</li>
</ul>
CSS:
#nav {
border-radius: 3px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
}
#nav, #nav ul {
list-style: none;
padding: 0;
width: 199px;
}
#nav ul {
position: relative;
z-index: -1;
}
#nav li {
position: relative;
z-index: 100;
}
#nav ul li {
margin-top: -23px;
-moz-transition: 0.4s linear 0.4s;
-ms-transition: 0.4s linear 0.4s;
-o-transition: 0.4s linear 0.4s;
-webkit-transition: 0.4s linear 0.4s;
transition: 0.4s linear 0.4s;
}
#nav li a {
background-color: #d4d5d8;
color: #000;
display: block;
font-size: 12px;
font-weight: bold;
line-height: 28px;
outline: 0;
padding-left: 15px;
text-decoration: none;
}
#nav li a.sub {
background: #d4d5d8 url("../images/down.gif") no-repeat;
}
#nav li a + img {
cursor: pointer;
display: none;
height: 28px;
left: 0;
position: absolute;
top: 0;
width: 200px;
}
#nav li a img {
border-width: 0px;
height: 24px;
line-height: 28px;
margin-right: 8px;
vertical-align: middle;
width: 24px;
}
#nav li a:hover {
background-color: #bcbdc1;
}
#nav ul li a {
background-color: #eee;
border-bottom: 1px solid #ccc;
color: #000;
font-size: 11px;
line-height: 22px;
}
#nav ul li a:hover {
background-color: #ddd;
color: #444;
}
#nav ul li a img {
background: url("images/bulb.png") no-repeat;
border-width: 0px;
height: 16px;
line-height: 22px;
margin-right: 5px;
vertical-align: middle;
width: 16px;
}
#nav ul li:nth-child(odd) a img {
background: url("images/bulb2.png") no-repeat;
}
#nav a.sub:focus {
background: #bcbdc1;
outline: 0;
}
#nav a:focus ~ ul li {
margin-top: 0;
-moz-transition: 0.4s linear;
-ms-transition: 0.4s linear;
-o-transition: 0.4s linears;
-webkit-transition: 0.4s linears;
transition: 0.4s linear;
}
#nav a:focus + img, #nav a:active + img {
display: block;
}
#nav a.sub:active {
background: #bcbdc1;
outline: 0;
}
#nav a:active ~ ul li {
margin-top: 0;
}
#nav ul:hover li {
margin-top: 0;
}
jsFiddle这里:http://jsfiddle.net/502n03eL/
答案 0 :(得分:2)
你可以尝试这个可能有用的CSS
#nav {
border-radius:3px;
-moz-border-radius:3px;
-webkit-border-radius:3px;
}
#nav, #nav ul, #nav ul ul {
list-style:none;
padding:0;
width:199px;
}
#nav ul, #nav ul ul {
position:relative;
z-index:-1;
}
#nav li {
position:relative;
z-index:100;
}
#nav ul li, #nav ul ul li {
margin-top:-23px;
-moz-transition: 0.4s linear 0.4s;
-ms-transition: 0.4s linear 0.4s;
-o-transition: 0.4s linear 0.4s;
-webkit-transition: 0.4s linear 0.4s;
transition: 0.4s linear 0.4s;
}
#nav li a {
background-color:#d4d5d8;
color:#000;
display:block;
font-size:12px;
font-weight:bold;
line-height:28px;
outline:0;
padding-left:15px;
text-decoration:none;
}
#nav li a.sub {
background:#d4d5d8 url("../images/down.gif") no-repeat;
}
#nav li a + img {
cursor:pointer;
display:none;
height:28px;
left:0;
position:absolute;
top:0;
width:200px;
}
#nav li a img {
border-width:0px;
height:24px;
line-height:28px;
margin-right:8px;
vertical-align:middle;
width:24px;
}
#nav li a:hover {
background-color:#bcbdc1;
}
#nav ul li a, #nav ul ul li a {
background-color:#eee;
border-bottom:1px solid #ccc;
color:#000;
font-size:11px;
line-height:22px;
}
#nav ul li a:hover {
background-color:#ddd;
color:#444;
}
#nav ul li a img, #nav ul li ul a img {
background: url("images/bulb.png") no-repeat;
border-width:0px;
height:16px;
line-height:22px;
margin-right:5px;
vertical-align:middle;
width:16px;
}
#nav ul li:nth-child(odd) a img, #nav ul ul li:nth-child(odd) a img {
background:url("images/bulb2.png") no-repeat;
}
#nav a.sub:focus {
background:#bcbdc1;
outline:0;
}
#nav a:focus ~ ul li ul li{
margin-top:-23px;
}
#nav a:focus ~ ul li {
margin-top:0;
-moz-transition: 0.4s linear;
-ms-transition: 0.4s linear;
-o-transition: 0.4s linears;
-webkit-transition: 0.4s linears;
transition: 0.4s linear;
}
#nav ul a:focus ~ ul li {
margin-top:0;
-moz-transition: 0.4s linear;
-ms-transition: 0.4s linear;
-o-transition: 0.4s linears;
-webkit-transition: 0.4s linears;
transition: 0.4s linear;
}
#nav a:focus + img, #nav a:active + img {
display:block;
}
#nav a.sub:active {
background:#bcbdc1;
outline:0;
}
#nav a:active ~ ul li, #nav ul a:active ~ ul li {
margin-top:0;
}
#nav ul:hover li {
margin-top:0;
}
你可以在这里看到小提琴fiddle