CSS伪类样式 a:hover中的背景图片background-image问题

html-css011

CSS伪类样式 a:hover中的背景图片background-image问题,第1张

注意样式表中,链接状态、鼠标悬停状态、已访问状态三个状态的先后顺序,顺序是:

先写“链接状态”的属性和值,次写“鼠标悬停状态”的属性和值,最后写“已访问状态”的属性和值。

.divmodules ul li a:link{}

.divmodules ul li a:hover{}

.divmodules ul li a:visited{}

可以在hover伪类中用background或者background-image实现。

例如:

页面上有一个

原本背景图为img1.png,当鼠标滑过则换为img2.png.

在CSS中这样定义

.div_style:hover{

background:

url("img2.png")

//这是改变背景色

background-repeat:

no-repeat

//这是让背景色不平铺

color:

red

//这是让字体变为红色

}

或者用

.div_style:hover{

background-image:

url("img2.png")

//这是改变背景色

background-repeat:

no-repeat//这是让背景色不平铺

color:red

//这是让字体变为红色

}