【发布时间】:2012-12-01 17:39:56
【问题描述】:
我在 .one (.one :hover) 类上放置了“悬停”功能,以将 background-color 更改为灰色。每当我将鼠标悬停在容器 .one div 上时,我都希望它突出显示 divs (.two, .three)。
但是,它的作用是将鼠标分别悬停在两个嵌套的 divs(.two、.three)上。有人可以解释为什么会这样以及我必须做些什么来突出显示整个 div .one 创建一个单一的纯灰色 div?
下面是我使用的 CSS。
.one {
width: 200px;
display: inline-block;
}
.two {
background-color: rgba(0, 51, 102, 1);
width: 50px;
height: 100px;
float: left;
}
.three {
background-color: rgba(0, 204, 204, 1);
width: 150px;
height: 100px;
float: right;
}
.one :hover {
background-color: rgba(153, 153, 153, 1);
}
<div class="one">
<div class="two">
</div>
<div class="three">
</div>
</div>
【问题讨论】:
标签: hover