Html div 悬停背景颜色变化?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9266669/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 22:31:03 来源:igfitidea点击:
div hover background-color change?
提问by Codette
How can I make it act as if a line of div is anchor so when I hover on it it returns to red
我怎样才能让它像一行 div 是锚一样,所以当我悬停在它上面时它会返回红色
CSS
CSS
.e
{
width:90px;
border-right:1px solid #222;
text-align:center;
float:left;
padding-left:2px;
cursor:pointer;
}
.f .e
{
background-color:#F9EDBE;
}
HTML
HTML
<div>
<div class="e" >Company</div>
<div class="e">Target</div>
<div class="e" style="border-right:0px;">Person</div>
</div>
<div class="f">
<div class="e">Company</div>
<div class="e">Target</div>
<div class="e" style="border-right:0px;">Person</div>
</div>
<div>
<div class="e">Company</div>
<div class="e">Targetaaa</div>
<div class="e" style="border-right:0px;">Person</div>
</div>
<div class="f">
<div class="e">Company</div>
<div class="e">Target</div>
<div class="e" style="border-right:0px;">Person</div>
</div>
回答by mgraph
.e:hover{
background-color:#FF0000;
}
回答by Ibu
if you want the color to change when you have simply add the :hover
pseudo
如果您希望在简单地添加:hover
伪代码时改变颜色
div.e:hover {
background-color:red;
}
回答by Love Kumar
div hover background color change
div 悬停背景颜色更改
Try like this:
像这样尝试:
.class_name:hover{
background-color:#FF0000;
}