在CSS中如何设置一个按钮鼠标划过变颜色。

html-css011

在CSS中如何设置一个按钮鼠标划过变颜色。,第1张

需要准备的材料分别有:电脑、浏览器、html编辑器。

1、首先,打开html编辑器,新建html文件,例如:index.html。

2、在index.html中的<style>标签中,输入css代码:button {background-color: #00a7d0}

button:hover {background-color: #ff7701}。

3、浏览器运行index.html页面,此时显示出了蓝色背景颜色的按钮。

4、将鼠标移入按钮,此时按钮的背景颜色变成了橙色。

1、首先,打开HTML编辑器并创建一个新的HTML文件,比如index.html。

2、在index.html中的<style>标签中,输入css代码:button {background-color: #00a7d0}

button:hover {background-color: #ff7701}。

3、当浏览器运行索引index.html页面中,出现蓝色背景颜色的按钮。

4、将鼠标移到按钮上,按钮的背景颜色将变为橙色。

鼠标经过改变边框颜色可以直接css的:hover伪类,然后定义border样式就是了。如下示例代码:

a{color:#000border:1px solid #000} /* 默认的样式 */

a:hover{border-color:#ccc} /* 鼠标经过时的样式 */

鼠标经过时将边框颜色变为了灰色。