CSS中设置鼠标悬停效果问题

html-css013

CSS中设置鼠标悬停效果问题,第1张

替换你相对应CSS,和html

-----------------CSS----------------------------

#dht .list2 span a

{

width:89pxheight:33pxdisplay:blockpadding-top:7pxcursor:pointer

}

#dht .list1 span a

{

width:89pxheight:33pxdisplay:blockpadding-top:7pxcursor:pointer

}

#dht .list1 span a:hover

{

background:#66CC00display:block

}

----------------------html--------------------------

<div class="list1"><span><a href="#">首 页</a></span></div>

css中悬停改变样式的最好方法是用伪类选择器div:hover{}。css代码示例如下:\x0d\x0a\x0d\x0adiv{width:100pxheight:200pxbackground:#000}\x0d\x0adiv:hover{background:#fff}\x0d\x0a\x0d\x0a这是一个修改背景颜色的示例,伪类里可以修改跟多的样式,宽度,高度或者字体大小,字体颜色都是可以修改的。