【发布时间】:2017-04-25 18:19:12
【问题描述】:
我创建了 jsfiddle,向你展示我的意思。
当悬停在文本上时,背景也应该有可能像悬停在 img/div 上时一样。目前,悬停效果仅在悬停在 div/img 上时有效,而在悬停在图像中间的文本上时无效。“a”链接也应在 div 和文本上工作。
https://jsfiddle.net/o5sxhssv/
HTML:
<!--First image-->
<div class="category_images_item">
<a href="">
<span>Watches</span>
<div class="category_images_img" style="background:url(https://static.pexels.com/photos/1279/fashion-wristwatch-time-watch.jpg)no-repeat center;background-size:cover;">
</div>
</a>
</div>
</div>
CSS:
.category_images{
margin: 0 auto
}
.category_images_item{
width: 400px;
height: 400px;
position: relative;
background-color: black;
overflow: hidden;
transition: all .8s ease;
margin: 10px;float: left
}
.category_images_item span{
color: white;
font-weight: bold;
font-size: 50px;
font-style: italic;
z-index: 100;
position: absolute;
width: 100%;
text-align: center;
top: 150px
}
.category_images_img{
background-size: cover;
width: 400px;
height: 400px;
transition: all .8s ease;
opacity: 0.7
}
.category_images_img:hover{
transform: scale(1.03) rotate(-1deg);
opacity: 0.5
}
非常感谢!! :))
【问题讨论】: