gpt4 book ai didi

html - 在下拉菜单上悬停全宽

转载 作者:太空宇宙 更新时间:2023-11-04 15:09:35 24 4
gpt4 key购买 nike

我对每个下拉菜单项的整个宽度的悬停效果有一些问题。我希望每个元素的背景颜色都改变。目前,我只能获取悬停文本的宽度,不能获取下拉列表的宽度。

http://jsfiddle.net/7AXZR/

谢谢!

HTML:

<div id="nav">

<ul>
<li><img src="images/kranz3.png" alt="kranz"/><a href="compete.php" id="competenav">COMPETE</a></li>
<li><img src="images/thumb3.png" alt="thumb"/><a href="score.php" id="scorenav">SCORE</a></li>
<div id="logolist"><li><a href="index.php"><img src="images/logorz.png" width="175em" /></a></li></div>
<li><img src="images/shopnav.png" alt="bag"/><a href="shop.php" id="shopnav">SHOP</a></li>
<ul id="more-dropdown"><li><img src="images/morenav2.png" alt="more"/><a href="#" id="morenav">MORE</a><ul>
<div id="dropdown-links">
<li><a href="printyourown.php">Print your own art</a></li>
<li><a href="compete.php">How it works</a></li>
<li><a href="causes.php">About Causes</a></li>
<li><a href="#">About our products</a></li>
<li><a href="#">About us</a></li>
<li><a href="#">Help & Feedback</a></li>
<li><a href="termsofservice.php">Terms of Service</a></li>
<li><a href="#">Privacy</a></li></ul>
</div>
</li>
</ul>
</div>
<div class="clear">
</div>

CSS:

#nav {
position:relative;
background:#ffffff;
width:100%;
height:0.2em:
overflow:visible;
margin-top:-2em;
font-family:Cusmyrb;
font-size:75%;

}

#logolist {
position:absolute;
padding-top:2em;
width:150px;
left:50%;
margin-left:-90px;
margin-top:-7%;

}


#nav ul {
list-style-type:none;

}

#nav li {
display:inline;
float:left;
width:20%;
margin-left:2%;
margin-right:2%;
margin-top:3%;
text-align:center;
}



#nav a {
display:block;
margin-right:0% auto;
padding-left:0% auto;
color:#343234;
text-decoration:none;


}

#nav a:hover {
color:#5020B8;
}

#nav a:active {
color:#5020B8;
}

.clear {
clear:both;
}

#more-dropdown {
margin: 0;
padding: 0;
height:0;
}

#more-dropdown li {
list-style: none;
float: left;
}



#dropdown-links li a {
float:left;
display: block;
font-family:Cusmyr;
font-size:14px;
background-color:#797A7D;
color:#797A7D;
text-decoration: none;
margin-top:0.5em;
margin-left:1em;
}

#dropdown-links li a:hover {
float:left;
display: block;
font-family:Cusmyr;
font-size:14px;
background-color:#01A07E;
color:#797A7D;
text-decoration: none;
margin-top:0.5em;
margin-left:1em;
}

#more-dropdown li ul {
display: none;
width: 6em; /* Width to help Opera out */
background-color:#797A7D;
border:1px solid white;
}

#more-dropdown li:hover ul {
display: block;
position: absolute;
margin: 0;
padding: 0; }
#more-dropdown li:hover li {
float: none;
background-color:#01A07E;
}
#more-dropdown li:hover li a {
color: #ffffff;
}
#more-dropdown li li a:hover {
}

最佳答案

切换

#nav a:hover

#nav:hover a

编辑:第一:你的<a> <li> 中的元素元素有上边距和左边距,因此它们不会填满整个列表项

第二个:#nav li选择器也适用于下拉列表中的列表项,您不希望它们 float 。这是因为周围的列表项的高度为 0

除了第一个列表项,我删除了 float :

新 fiddle : http://jsfiddle.net/PZGLz/

关于html - 在下拉菜单上悬停全宽,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15487394/

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