关于css的:hover

html-css020

关于css的:hover,第1张

按照你这样的布局是要配合js才可以的,还有你的html代码有点问题,不符合规范,一般都是<li>包含<a>的,你为什么不从html上解决呢?

像这样

<ul class="no_style_ul">

<li class="index"><a href="">首页</a></li>

</ul>

然后css像下面这样

<style>

.no_style_ul li.index{ float:leftwidth:宽height:高background:url(你的那张ico背景图) left center no-repeatpadding-left:你那张ico的宽+5px}

.no_style_ul li.index:hover{background:url(变了颜色的ico背景图) left center no-repeat}

</style>

这样就解决了

希望对你有所帮助!

看错了

.div1:hover .div2{background-color: red}  

这一句应该写成

.div1:hover ~div{background-color: red}