我正在尝试实现悬停效果 当我悬停列表项时,在我的图标上。在我的下拉菜单中。
我添加了一个codepen,您可以快速查看我的问题所在。 正如您可以看到所有突出显示的工作,除了图像。 我知道这是因为我只改变背景颜色。 上悬停。但是我该如何正确地做到这一点以达到预期的效果呢?
亲切的问候, DDaems
http://codepen.io/anon/pen/KEiym
CSS
#userbar {
font-size:12px;
position:fixed;top:0; left:0;
width:1170px;height:2.636em;
margin:auto;padding:0;
color:#b5b5b5;background-color:rgb(51,51,51);
border-bottom:2px solid #b5b5b5;
opacity:0.95;z-index: 1
}
#menubar {
position:relative;float:left; /* Clear floats */
margin-top:0;margin-bottom:0;margin-left:5%;
min-width:27.273em;/* 300px */height:2.636em;
padding: 0 0 0 0;
text-align:left;font-weight:bold;white-space:nowrap;
list-style:none;
z-index:5
}
#menubar li {
position:relative;float:left;
width:115px;
margin-right:0;
padding-top:0;padding-bottom:0;
background:rgb(51,51,51);
/* vertical-align:-25; */
}
#menubar a {
display:block;
min-width: 115px;
height:20px;
padding-top:0;
color:#b5b5b5;line-height:28px;text-decoration:none
}
#menubar a:hover {
color:#fff; text-decoration:underline
}
#menubar .menutitleimg {
float:left;
min-width:2.636em;max-width:2.636em;
min-height:2.636em;max-height:2.636em; /* 29px */
background-color:rgb(51,51,51);
}
#userbar .NoIconFix {
float:left;
min-width:0.001em;max-width:0.001em;
min-height:2.636em;max-height:2.636em; /* 29px */
/* background-color:grey */
}
#menubar ul{
background:rgb(51,51,51); /* Adding a background makes the dropdown work properly in IE7+ */
background:rgba(51,51,51,0); /* Lets make it fully transparent, we don't actually want to see */
width:auto;
list-style:none;
position:absolute;
left:-9999px /* Hide off-screen when not needed (this is more accessible than display:none;) */
}
#menubar ul li{
box-sizing:border-box;
width: auto;
padding: 0px;
padding-left: 3px;
border: 2px solid #b5b5b5;
border-bottom: 0px;
border-top: 0;
white-space:nowrap;
}
#menubar ul a{
white-space:nowrap; /* Stop text wrapping and creating multi-line dropdown items */
}
#menubar li:hover ul{ /* Display the dropdown on hover */
left: -2px; /* Bring back on-screen when needed */
top: 2.636em;
z-index: -1;
margin: 0 3px;
padding: 0 0 0 0;
background:rgb(51,51,51);
overflow:visible;
border-top: none;
height: auto;
}
#menubar li:hover ul li ul{
background:rgb(51,51,51); /* Adding a background makes the dropdown work properly in IE7+ */
background:rgba(51,51,51,0); /* Lets make it fully transparent, we don't actually want to see */
list-style:none;
border: 2px solid #b5b5b5;
left:-9999px /* Hide off-screen when not needed (this is more accessible than display:none;) */
}
#menubar li:hover ul li:hover ul{
left:115px; /* Bring back on-screen when needed,
i need this to autodecide the 'left'*/
top: 0;
z-index: -1;
overflow:visible;
background:rgb(51,51,51);
border-top: none;
height: auto;
}
#menubar li:hover ul li:hover ul li ul{
background:rgb(51,51,51);
background:rgba(51,51,51,0);
list-style:none;
position:absolute;
left:-9999px
}
#menubar li:hover ul li:hover ul li:hover ul{
left: 115px; /* Bring back on-screen when needed */
top: 0;
z-index: -1;
overflow:visible;
background:rgb(51,51,51);
border-top: none;
height: auto;
}
#menubar li:hover ul li:hover ul likl{
border-left: 2px solid #b5b5b5; border-right:2px solid #b5b5b5}
#menubar li:hover ul li:hover ul li:first-child {
border-bottom:0;border-left:0;border-right:0;border-top:2px solid #b5b5b5}
#menubar li:hover ul li:hover ul li:hover ul li:first-child{
border-top:0;border-left:0;}
#menubar li:hover ul li:hover .noborder{
border-right:0; }
#menubar li:hover ul li:hover{
position:relative;
color: #fff;
}
#menubar li:hover a{
text-decoration:underline;
color:#fff;
z-index: -1;
}
#menubar li:hover ul a{
text-decoration:none;
padding-bottom:5px;
color:#b5b5b5;
}
#menubar li ul li:hover {
/* Defines the most explicit hover stat--what happens if you hover each individual list item */
background:rgba(71,71,71,0.8);
width:auto;
}
#menubar li:hover ul li a:hover{
/* Here we define the most explicit hover states--what happens when you hover each indi link. */
background:rgba(71,71,71,0.8);
color:#fff;
}
#menubar li ul li.disablehover{
/* Here we define the most explicit hover states--what happens when you hover each indi link */
background:rgba(51,51,51,0.8);
font-weight:bold;
height: auto;
margin:0;
border-bottom: 2px solid #515151;
line-height:20px;
}
#menubar li.userbar_time a{
margin-top:0.364em;
font-size: 0.909em;
text-align: center;
line-height: 1.091em;
white-space:normal;
}
.menuimg{
float:left;
width:auto;
max-width:auto;
min-height:auto;
max-height:auto;
}
HTML
<div id="userbar">
<ul id="menubar">
<li><span class="NoIconFix"> $l_avatar$username</span>
<ul>
<li class="disablehover"> $usernameid</li>
<li><a href="index.php?site=loginoverview"><img class="menutitleimg" src="http://www.clker.com/cliparts/U/b/3/E/T/z/ok-icon-md.png">overview</a></li>
<li><a href="index.php?site=myprofile"><img class="menutitleimg" src="http://www.clker.com/cliparts/U/b/3/E/T/z/ok-icon-md.png"> edit_account</a></li>
<li><a href="index.php?site=messenger"> PM Inbox</a></li>
<li><a href="index.php?site=buddys"> Buddys</a></li>
<li><a href="index.php?site=usergallery"> galleries</a></li>
<li><a href="index.php?site=myprofile&action=gameaccounts"> Gameaccounts</a></li>
<li><a href="index.php?site=matches&action=viewmatches&memberID=$userID"> My Matches</a> </li>
<li><a href="logout.php"> Logout</a></li>
</ul>
</li>
<li>
<img class="menutitleimg" src="http://www.clker.com/cliparts/U/b/3/E/T/z/ok-icon-md.png">
<a href="index.php?site=teams"> Teams</a>
<ul>
<li><a href="index.php?site=teams"> My Teams</a>
<ul>
<li class="noboder"><a href="index.php?site=CLAN"> CLANNAME</a>
<ul>
<li><a href="index.php?site=clans&action=clanedit&clanID=1"> Edit Team</a></li>
<li><a href="index.php?site=matches&action=viewmatches&clanID=1"> Team Matches</a></li>
<li><a href="index.php?site=clans&action=show&clanID=1"> Team Details</a></li>
<li><a href="index.php?site=clans&action=editpwd&clanID=1">Edit Password</a></li>
<li><a href="index.php?site=clans&action=invite&clanID=1">E-mail Invitation</a></li>
<li><a href="index.php">chat</a></li> <!-- TeamChat -->
</ul>
</li>
</ul>
</li>
<li><a href="index.php?site=clans&action=clanjoin">Join Team</a></li>
<li><a href="index.php?site=clans&action=clanadd">Create Team</a></li>
<li><a href="index.php?site=clans">All Teams/ search</a></li>
</ul>
</li>
<li>
<img class="menutitleimg" src="images/menu/level.png">
<a href="#">Placeholder</a>
<ul>
<li><a href="index.php?site=clans&action=invite&clanID=1">Placeholder</a></li>
<li><a href="#">Placeholder</a></li>
<li><a href="#">Placeholder</a></li>
<li><a href="#">Placeholder</a></li>
</ul>
</li>
<li>
<img class="menutitleimg" src="images/menu/games.png">
<a href="#">Leagues</a>
<ul>
<li><a href="index.php?site=cups">Tournaments</a></li>
<li><a href="index.php?site=quicknavi">Signups</a></li>
<li><a href="#">Placeholder</a></li>
<li><a href="#">Placeholder</a></li>
<li><a href="#">Placeholder</a></li>
</ul>
</li>
<li>
<img class="menutitleimg" src="images/menu/message.png">
<a href="#">Contact</a>
<ul>
<li><a href="#">Placeholder</a></li>
<li><a href="#">Placeholder</a></li>
<li><a href="#">Placeholder</a></li>
</ul>
</li>
<!-- this will be the right side of the userbar-->
<li class="userbar_time"><span class="NoIconFix"><a href="?site=myprofile&action=timezone&userID=$userID">$local_date_user<br />$local_hour_user</a></span>
<ul>
<li><a href="?site=myprofile&action=timezone&userID=$userID">Set timezone</a></li>
</ul>
</li>
<li><a href="?site=forum">Forum</a></li>
</ul>
</div>