我有以下div狭窄。CSS悬停防止受到影响的孩子
<div class="profile_outer>
<div class="profile"></div>
</div>
下面CSS
.profile_outer {
border: 2px solid #660000;
-moz-border-radius: 5px;
border-radius: 5px;
-webkit-border-radius: 5px;
}
.profile {
width: 198px;
height: 225px;
border: 1px solid #660000;
-moz-border-radius: 5px;
border-radius: 5px;
-webkit-border-radius: 5px;
z-index: 100;
}
.profile_outer:hover {
background-color: blue;
}
,你可以找到fiddle here
双方的div没有背景,背景由一些家长格的图像来确定。所以它们是透明的。
因此,在悬停我只是想改变外部配置文件的背景。
.profile_outer:hover .profile {
display: block;
background : none !important;
background-color:transparent;
}
感谢您的帮助:这只是如果我还更改使用
.profile_outer:hover .profile {
display: block;
background : #fff; // but I do NOT want to change the background
}
我想这些了以下组合内div的背景色工作。
+1,巧妙的解决方案。虽然我认为OP实际上想要'.profile_outer:hover .profile {box-shadow:0px 0px 1000px blue;}'(http://jsfiddle.net/gJpbG/2/) – Moob
辉煌,谢谢! –