css里鼠标悬停变色怎么设置?

html-css019

css里鼠标悬停变色怎么设置?,第1张

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

background-color:rgba(220,38,38,0.2)

background:red

opacity:0.2

背景设置透明度

css鼠标悬停伪类 :hover 使用方式如下

<div class="test">则是测试div</div>

.test: hover {

color: orange

font-weight: bold

}

当鼠标悬停在 div test 上时,test里面的文字会加粗,颜色变为橘色。

鼠标悬停伪类在手机端是看不到效果的,因为手机端是触屏的