9

Below code works fine in ie 9 and doesn't work in any other browser. When I mouse hover on list background should change the color, but it doesn't.

.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>

3
  • 2
    menunews class you have mentioned it for the li ,hence the css should have been li.menunews a:hover{....} Commented Jun 29, 2013 at 5:37
  • does your parent div of the ul have .menunews class??, because you have written the css that way, Commented Jun 29, 2013 at 5:41
  • jsfiddle.net/Kritika/L767M check out this jsfiddle Commented Jun 29, 2013 at 5:44

3 Answers 3

11

hey actually you made the CSS in some other way that's why browsers doesn't understand your css code so i made some changes in your css and its working fine on all browsers as per your requirement so i hope this will help you.....

ul li.menunews {
    border-bottom: 1px solid #ccc;  
    list-style:none; 
    height:30px;
}
ul li.menunews a {
    display:block;
    color:#266CAE;
    text-decoration:none;
}
    
ul li.menunews: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>

Sign up to request clarification or add additional context in comments.

Comments

3

Define your class in ul instead of li so as to take effect :

<ul class="menunews" style="font-size:12px;"><li ><a href="#" >

1 Comment

Here’s a jsFiddle demo of this fix. That demo also has reformatted HTML and CSS to make the code easier to read and edit, and I fixed two occurences of a hyphen having a space after it that should not be there (text- decoration and color- stop).
2

you have mentioned menunews class to li, the css should have been li.menunews ,use the below css code

 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;
        }

 li.menunews 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;
      }

Please see this DEMO

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.