当我将鼠标悬停在子菜单上时,有没有办法保持a:hover {color:#ffffff }
白色?
答案 0 :(得分:1)
替换此行:
.sf-menu li a:hover { color:#ffffff; }
通过这个:
.sf-menu li:hover a { color:#ffffff; }
/*** ESSENTIAL STYLES ***/
.sf-menu, .sf-menu * {
margin: 0;
padding: 0;
list-style: none;
}
.sf-menu li {
position: relative;
}
.sf-menu ul {
position: absolute;
display: none;
top: 100%;
left: 0;
z-index: 99;
}
.sf-menu > li {
float: left;
}
.sf-menu li:hover > ul,
.sf-menu li.sfHover > ul {
display: block;
}
.sf-menu li { text-transform:uppercase; color:#555a60; }
.sf-menu a {
display: block;
position: relative;
}
.sf-menu ul ul {
top: 0;
left: 100%;
}
.sf-menu i {
position:absolute;
margin:1px 4px;
font-size:18px;
color:#dfd301;
}
.sf-menu i:hover { color:#ffffff; }
/*** DEMO SKIN ***/
.sf-menu {
float: left;
margin-bottom: 1em;
}
.sf-menu ul {
box-shadow: 2px 2px 6px rgba(0,0,0,.2);
min-width: 12em; /* allow long menu items to determine submenu width */
*width: 12em; /* no auto sub width for IE7, see white-space comment below */
}
.sf-menu a {
min-width: 113px;
text-align: center;
padding:20px 16px;
text-decoration: none;
zoom: 1; / IE7 /
}
.sf-menu a {
color: #555a60;
}
.sf-menu li {
/*background: #BDD2FF;*/
white-space: nowrap; /* no need for Supersubs plugin */
*white-space: normal; /* ...unless you support IE7 (let it wrap) */
-webkit-transition: background .2s;
transition: background .2s;
}
.sf-menu li ul li a { padding:10px; text-align:left; color:#ffffff; }
.sf-menu li ul li a:hover { color:#ffffff; }
.sf-menu li ul li { background:#777777; color:#ffffff; }
.sf-menu ul li {
min-width:180px;
text-transform:uppercase; color:#555a60;
}
.sf-menu ul ul li {
background: #9AAEDB;
}
.sf-menu li:hover,
.sf-menu li.sfHover {
background: #b01523;
color:#ffffff;
/* only transition out, not in */
-webkit-transition: none;
transition: none;
}
.sf-menu li:hover a { color:#ffffff; }
/*** arrows (for all except IE7) **/
.sf-arrows .sf-with-ul {
padding-right: 2.5em;
*padding-right: 1em; /* no CSS arrows for IE7 (lack pseudo-elements) */
}
/* styling for both css and generated arrows */
.sf-arrows .sf-with-ul:after {
content: '';
position: absolute;
top: 50%;
right: 1em;
margin-top: -3px;
height: 0;
width: 0;
/* order of following 3 rules important for fallbacks to work */
border: 5px solid transparent;
border-top-color: #dFeEFF; /* edit this to suit design (no rgba in IE8) */
border-top-color: rgba(255,255,255,.5);
}
.sf-arrows > li > .sf-with-ul:focus:after,
.sf-arrows > li:hover > .sf-with-ul:after,
.sf-arrows > .sfHover > .sf-with-ul:after {
border-top-color: white; /* IE8 fallback colour */
}
/* styling for right-facing arrows */
.sf-arrows ul .sf-with-ul:after {
margin-top: -5px;
margin-right: -3px;
border-color: transparent;
border-left-color: #dFeEFF; /* edit this to suit design (no rgba in IE8) */
border-left-color: rgba(255,255,255,.5);
}
.sf-arrows ul li > .sf-with-ul:focus:after,
.sf-arrows ul li:hover > .sf-with-ul:after,
.sf-arrows ul .sfHover > .sf-with-ul:after {
border-left-color: white;
}
<ul class="sf-menu">
<li><a href="#">home</a></li>
<li>
<a href="#">blog</a>
<ul>
<li><a href="#">Option1</a></li>
<li><a href="#">Option2</a></li>
<li><a href="#">Option3</a></li>
</ul>
</li>
<li><a href="#">page</a>
</li>
<li><a href="#">contact</a>
</li>
</ul>
答案 1 :(得分:0)
在第95行,你可以.sf-menu li:hover a
关键是你在li上使用:hover
并在它之后进一步遍历。
答案 2 :(得分:0)
将:悬停在整个li
上
我在你的CSS末尾添加了这个,它似乎有效。
.sf-menu > li:hover > a {
color: white;
}
这可能是一个更好的地方,但那里有很多代码...