-1

如何使我的锚与父列表项的确切大小匹配?目前它显示元素本身的大小。

CSS:

ul li a{color: black;background:url(http://mwv3.webs.com/menu_hover.png)-20px bottom no-repeat;
padding:0px 0px 9px 0px;width:100%;
    -webkit-transition: background .5s ease;
     -moz-transition: background .5s ease;
       -o-transition: background .5s ease;
      -ms-transition: background .5s ease;
          transition: background .5s ease;
}

ul li a:hover{
 background:url(http://mwv3.webs.com/menu_hover.png) center bottom 
}

html

<div id="wrapper">
 <div class="nav">
   <ul>
     <li><a href="#">One</a></li>
     <li><a href="#">One</a></li>
     <li><a href="#">One</a></li>
     <li><a href="#">One</a></li>
     <li><a href="#">One</a></li>
   </ul>
 </div>
</div>

谢谢

4

1 回答 1

0

只需使用这个 css 就可以在jsfiddle上正常工作

ul li a{color: black;background:url(http://mwv3.webs.com/menu_hover.png)-20px bottom no-repeat;
    padding:0px 0px 9px 0px;width:100%;
        -webkit-transition: background .5s ease;
         -moz-transition: background .5s ease;
           -o-transition: background .5s ease;
          -ms-transition: background .5s ease;
              transition: background .5s ease;
    display:block;/*ADDED*/
}

ul li a:hover{

background:url(http://mwv3.webs.com/menu_hover.png) center bottom no-repeat; /*Changed*/
}
于 2013-09-09T10:35:49.320 回答