在CSS中如何实现鼠标移上去后,字体变颜色?

html-css024

在CSS中如何实现鼠标移上去后,字体变颜色?,第1张

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

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

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

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

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

<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>无标题文档</title>

</head>

<body>

<a href="javascript:" style="color:#333"><span style="color:#f00">啦啦啦啦啦啦啦<span></a>

</body>

</html>

运行结果:

下划线的颜色是在a标签上面设置的,字体颜色在span标签上设置的