效果演示
初始显示
显示效果
页面代码
<div class="item">
<div class="text">
<span class="tip">Household DIY</span>
<div class="move">
<p>Vases</p>
<p>Decoration Material</p>
<p>Lanterns</p>
<p>Living Room Decoration</p>
<p>Decoration Pots</p>
<p>Artificial Flowers</p>
<p>LED Items</p>
<p>Decoration Trays/Plate</p>
<p>Papeterie</p>
</div>
</div>
<img src="static/images/index/s2_1.png" alt="" />
</div>
效果实现
黑色背景
.item:hover::after{
content: '';
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
background: rgba(0, 0, 0, 0.5);
z-index: 1;
}
字显示
方法一: 通过css控制
.section2 .carousel .item:hover > .text>.move {
opacity: 1;
}
方法二: 通过jquery中的hover控制
样式名
.section2 .carousel .item .text .move{
opacity: 0;
transition: 1s;
}
.section2 .carousel .item .text .move-active{
opacity: 1;
}
事件内容
$('.section2 .carousel .item').hover(function(){
$(this).children(".text").children('.move').addClass("move-active")
},function(){
$(this).children(".text").children('.move').removeClass("move-active")
}
)
方法三: 通过jquery中的mouseover和mouseleave控制
$('.section2 .carousel .item').mouseover(function(){
$(this).children(".text").children('.move').addClass("move-active")
})
$('.section2 .carousel .item').mouseleave(function(){
$(this).children(".text").children('.move').removeClass("move-active")
})