我在父div中有2个div ..我需要父div在悬停时变得明亮.. 这是小提琴.. 我尝试使用悬停,但无法得到它......任何帮助,请
HTML:
<div class="parent" style="border:1px solid black;">
<div class="one">
<img class="img1" src="http://static.howstuffworks.com/gif/vincent- van-gogh-paintings-from-saint-remy-2.jpg"/>
</div>
<div class="two">
<img class="img2" src="http://static.howstuffworks.com/gif/vincent-van-gogh-paintings-from-saint-remy-2.jpg"/>
</div>
</div>
答案 0 :(得分:1)
首先,您在CSS .parent hover
中拥有此功能。但它需要:
而不是空格,如:.parent:hover
。
同时从style
div中删除parent
属性。只需在CSS中定义边框即可。
现在,您应该能够使用hover
课程中的parent
:http://jsfiddle.net/d9yPK/4/
答案 1 :(得分:1)
将内联样式移动到样式表:
<div class="parent"> <!-- remove style="border:1px solid black" -->
将CSS更改为:
.parent {
position:relative;
height:50px;
width:200px;
border:1px solid black;
}
.parent:hover { /* you forgot the : here */
border-color:blue;
}