div悬停背景颜色变化?


71

如何使其表现得像div线是锚点一样,所以当我将鼠标悬停在它上面时,它会变成红色

的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 div上时,是否要使f的所有sub div具有背景颜色
mgraph 2012年

Answers:



35

如果您想在仅添加:hover伪色时更改颜色

div.e:hover {
    background-color:red;
}

连续有三个e div。我想要的是能够更改所有row.not一个“ e” div。
Codette 2012年

@tfeseas在这种情况下,您可以将财产放到父级div
Ibu,

0

div悬停背景颜色更改

尝试这样:

.class_name:hover{
    background-color:#FF0000;
}
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.