您可以通过两种方法实现您的结果:-
第一种方法定义位置值:-
HTML
<ul>
<li>Hello</li>
<li>Hello world</li>
</ul>
CSS
ul{
width:100px;
}
ul li{
border:1px solid orange;
background: url("http://www.adaweb.net/Portals/0/Images/arrow1.gif") no-repeat 90% 5px;
}
ul li:hover{
background: yellow url("http://www.adaweb.net/Portals/0/Images/arrow1.gif") no-repeat 90% 5px;
}
第一个演示:- http://jsfiddle.net/QeGAd/18/
CSS 的第二种方法:before:after选择器
HTML
<ul>
<li>Hello</li>
<li>Hello world</li>
CSS
ul{
width:100px;
}
ul li{
border:1px solid orange;
}
ul li:after {
content: " ";
padding-right: 16px;
background: url("http://www.adaweb.net/Portals/0/Images/arrow1.gif") no-repeat center right;
}
ul li:hover {
background:yellow;
}
ul li:hover:after {
content: " ";
padding-right: 16px;
background: url("http://www.adaweb.net/Portals/0/Images/arrow1.gif") no-repeat center right;
}
第二个演示:- http://jsfiddle.net/QeGAd/17/