【发布时间】:2013-06-29 04:59:52
【问题描述】:
下面的代码在 ie 9 中运行良好,在任何其他浏览器中都无法运行。当我将鼠标悬停在列表背景上时应该改变颜色,但它没有。
.menunews ul {
margin: 0px;
padding: 0px;
list-style-type: none;
}
.menunews a {
display: block;
color: #266CAE;
height: 30px;
background: #ffffff;
border-bottom: 1px solid #ccc;
overflow: hidden;
width: 100%;
height: 2.72em;
line-height: 2.75em;
text-indent: 2.02em;
text-decoration: none;
}
.menunews li a:hover {
background: #ffffff;
background: -moz-linear-gradient(top, #ffffff 0%, #f6f6f6 47%, #ededed 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #ffffff), color- stop(47%, #f6f6f6), color-stop(100%, #ededed));
background: -webkit-linear-gradient(top, #ffffff 0%, #f6f6f6 47%, #ededed 100%);
background: -o-linear-gradient(top, #ffffff 0%, #f6f6f6 47%, #ededed 100%);
background: -ms-linear-gradient(top, #ffffff 0%, #f6f6f6 47%, #ededed 100%);
background: linear-gradient(to bottom, #ffffff 0%, #f6f6f6 47%, #ededed 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#ededed', GradientType=0);
color: #266CAE
}
<ul style="font-size:12px;">
<li class="menunews">
<a href=""><span style="margin-left:2px;">Hello test</span></a>
</li>
</ul>
【问题讨论】:
-
menunews 类你已经为 li 提到了它,因此 css 应该是 li.menunews a:hover{....}
-
ul 的父 div 有 .menunews 类吗??因为你是这样写 css 的,
-
jsfiddle.net/Kritika/L767M 看看这个 jsfiddle