这是我的悬停状态的html和css代码。
HTML:
<div class="col-3">
<div class="popular"> <a href="#" ><img src="http://s10.postimg.org/4zqkz9rxl/saina_2.png"/></a></div>
</div>
的CSS:
div.col-3 {
-webkit-column-count: 3;
-webkit-column-gap: 10px;
-moz-column-count: 3;
-moz-column-gap: 10px;
column-count:3;
column-gap:10px;
margin:20px 30px;
}
.popular:hover {
opacity:0.7;
background-color:#FF1493;
}
这是我的jsfiddle:http://jsfiddle.net/7sbw18j0/
当我悬停图像时,它不会显示具有不透明度的粉红色。
任何人都可以帮助我吗?提前谢谢。
答案 0 :(得分:2)
div.col-3 {
-webkit-column-count: 3;
-webkit-column-gap: 10px;
-moz-column-count: 3;
-moz-column-gap: 10px;
column-count: 3;
column-gap: 10px;
margin: 20px 30px;
}
.popular {
background-color: #FF1493; /* added background for parent not image so that the background is visible when hovered */
}
.popular img {
vertical-align: middle; /* added to remove extra space below */
}
.popular img:hover {
opacity: 0.7; /* decrease image opacity on hover */
}
<div class="col-3">
<div class="popular">
<a href="#">
<img src="http://s10.postimg.org/4zqkz9rxl/saina_2.png" />
</a>
</div>
</div>
答案 1 :(得分:0)
检查一下:
<强> HTML 强>
<div class="col-3">
<div class="popular"> <a href="#"><img src="http://s10.postimg.org/4zqkz9rxl/saina_2.png"/></a>
</div>
</div>
<强> CSS 强>
div.col-3 {
-webkit-column-count: 3;
-webkit-column-gap: 10px;
-moz-column-count: 3;
-moz-column-gap: 10px;
column-count:3;
column-gap:10px;
margin:20px 30px;
}
.popular {
overflow:hidden;
}
.popular:hover {
background:#FF1493;
}
.popular:hover img {
opacity:0.7;
}