正在回答
1回答
使用:hover伪类,当鼠标移到元素上时,在此元素添加特殊的样式:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | <!DOCTYPE html> < html lang = "en" > < head > < meta charset = "UTF-8" > < meta name = "viewport" content = "width=device-width, initial-scale=1.0" > < meta http-equiv = "X-UA-Compatible" content = "ie=edge" > < title >Document</ title > < style > a { display: block; width: 150px; height: 150px; line-height: 150px; text-align: center; text-decoration: none; } a:hover { background-color: red; } </ style > </ head > < body > < div width=“150px” height=“150px”> < a href = "#" >变色</ a > </ div > </ body > </ html > |
祝学习愉快!
前端小白入门系列课程
- 参与学习 人
- 提交作业 11218 份
- 解答问题 36712 个
从一个不会编程的小白到一个老司机是需要过程的,首先得入门,学习基础知识,然后才能进阶,最后再到精通,本专题是你走进前端世界的不二选择!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧