- S笔记
-
需要准备的材料分别有:电脑、浏览器、html编辑器。
1、首先,打开html编辑器,新建html文件,例如:index.html。
2、在index.html中的<style>标签中,输入css代码:
div{height: 80px; background: url(small3.png)}div:hover{background: url(small2.png)}。
3、浏览器运行index.html页面,此时div显示的背景图片是small3.png。
4、将鼠标移入div,此时背景图片自动变更成了small2.png。
- LocCloud
-
可以在hover伪类中用background或者background-image实现。
例如:
页面上有一个<div class="div_style"></div>原本背景图为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; //这是让字体变为红色
}
- 陶小凡
-
背景图 大小及拉伸 都不可设置,只能设置显示的边距
- max笔记
-
css代码:
a:hover{background-image:url(图片2);color:red;}
- 左迁
-
css代码:
a:hover{background-image:url(图片2);color:red;}