[英]change background of a div containing divs
I'm sure the answer is really simple, but I can't figure this out : 我确定答案很简单,但我无法弄明白:
http://jsfiddle.net/VfQAH/ http://jsfiddle.net/VfQAH/
I have a bunch of divs in a table style layout like so : 我在表样式布局中有一堆div,如下所示:
<div class="row">
<div class="col boxname">Box Name</div>
<div class="col length">Length</div>
<div class="col width">Width</div>
<div class="col height">Height</div>
</div>
<div class="row">
<div class="col boxname">A</div>
<div class="col length">1</div>
<div class="col width">2</div>
<div class="col height">3</div>
</div>
<div class="row">
<div class="col boxname">B</div>
<div class="col length">1</div>
<div class="col width">2</div>
<div class="col height">3</div>
</div>
I want rows to change color on hover, for that I have : 我希望行在悬停时改变颜色,因为我有:
.row :hover{
background: #003366;
}
But the background changes only on the hovered cell, instead of the whole row. 但背景仅在悬停的细胞上改变,而不是整行。 Do I have to use JS to make it happen like I want, or is there a simple CSS trick that I don't know? 我是否必须使用JS来实现我想要的,或者是否有一个我不知道的简单CSS技巧?
You'd use .row:hover
instead of .row :hover
to highlight the whole row. 您可以使用.row:hover
而不是.row :hover
来突出显示整行。
.row:hover{
background: #003366;
}
Your original selector, .row hover
, selects all hovered elements which descend from .row
, instead of .row
itself. 你的原始选择器.row hover
,选择从.row
下降的所有悬停元素,而不是.row
本身。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.