div 悬停背景颜色变化?

2022-01-22 00:00:00 hover html css

我怎样才能让它表现得好像一行 div 是锚点,所以当我将鼠标悬停在它上面时它会返回红色

CSS

.e{宽度:90 像素;右边框:1px 实心 #222;文本对齐:居中;向左飘浮;填充左:2px;光标:指针;}.f.e{背景颜色:#F9EDBE;}

HTML

<div class="e" >公司</div><div class="e">目标</div><div class="e" style="border-right:0px;">人</div></div><div 类="f"><div class="e">公司</div><div class="e">目标</div><div class="e" style="border-right:0px;">人</div></div>

<div class="e">公司</div><div class="e">Targetaaa</div><div class="e" style="border-right:0px;">人</div></div><div 类="f"><div class="e">公司</div><div class="e">目标</div><div class="e" style="border-right:0px;">人</div></div>

解决方案

.e:hover{背景颜色:#FF0000;}

How can I make it act as if a line of div is anchor so when I hover on it it returns to red

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

<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>  

解决方案

.e:hover{
   background-color:#FF0000;
}

相关文章