可以使用CSS中的:hover伪类来设置链接鼠标悬停时的状态。具体方法如下:
css
a:hover {
color: red; /* 鼠标悬停时链接文字变成红色 */
text-decoration: underline; /* 鼠标悬停时给链接添加下划线 */
}
在上述代码中,我们使用了:hover伪类来表示鼠标悬停状态下的链接样式。在大括号中,我们可以设置相应的样式属性,如color和text-decoration等。
使用高亮颜色和代码块展示完整代码如下:
css
/* 设置链接鼠标悬停时的状态 */
h3 {
color: #0077cc; /* 使用高亮颜色显示小标题 */
margin-bottom: 10px;
}
pre {
background-color: #eee; /* 使用浅灰色的背景色显示代码块 */
padding: 10px;
}
p {
margin-bottom: 20px;
}
a:hover {
color: red; /* 鼠标悬停时链接文字变成红色 */
text-decoration: underline; /* 鼠标悬停时给链接添加下划线 */
}
2023-05-06 12:48:22 更新