【发布时间】:2018-11-23 19:03:26
【问题描述】:
我有以下 html 代码,我正在尝试更改 div 标签的背景颜色,这样当我将鼠标悬停在文本上时,背景应该变成灰色,但是当我将鼠标移出标签,它应该变成白色。我正在尝试使用 css 来做到这一点,但我很难想出代码。这可能只使用css吗?谁能给我举个例子?
<div class="custom-select">
<div style="background-color: grey;">TEST 1</div>
<div style="background-color: white;">TEST 2</div>
</div>
提前致谢。
【问题讨论】:
-
为了让我们更好地帮助您,请更新您的问题,以便在minimal, complete, and verifiable example 中显示您的相关代码。如果您可以让我们知道what you have tried so far 来解决您的问题,将会很有帮助。更多信息请参考how to ask good questions的帮助文章。
-
可能重复:[div 背景颜色,改变悬停状态](stackoverflow.com/questions/676324/…)
标签: css