鼠标未选中
鼠标选中
直接上html代码
<!-- 宣传栏 -->
<div class="billboards">
<img src="./images/images1/bgimg1.png" alt="" />
<div class="mask"></div>
<div class="world">
<p class="p1">包图教育</p>
<p class="p2">专注教育20年</p>
<p class="p3">
精品UI界面创意ICON、界面、BANNER,这里应有尽有!精品UI界面创意ICON界面、BANNER,这里应有尽有!
</p>
<div><a href="">点击查看</a></div>
</div>
</div>
css代码
.billboards{
position: relative;
height: 46vw;
}
.billboards img{
position: absolute;
width: 100%;
}
.billboards .world{
position: absolute;
margin: 0 36vw;
}
.billboards .world .p1{
text-align: center;
margin-top: 12vw;
font-size: 7vw;
color: #fff;
}
.billboards .world .p2{
margin-top: 2vw;
text-align: center;
font-size: 3vw;
color: #fff;
}
.billboards .world .p3{
margin-top: 3vw;
width: 29vw;
height: 3vw;
font-size: 1vw;
color: #fff;
line-height: 2vw;
text-align: center;
font-weight: lighter;
}
.billboards .world div{
display: flex;
width: 16vw;
height:5vw;
margin: 3vw auto;
background-color:white;
align-items: center;
justify-content: center;
}
.billboards .world div a{
text-align: center;
color: #fecf3b;
font-size: 3vw;
}
.billboards .mask{
display: none;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 46vw;
background-color: rgba(0,0,0,0.5);
}
.billboards:hover .mask{
display: block;
}
整体思路就是运用子绝父相布局将整个大盒子设置为相对定位,图片和文字设置为绝对定位,再用伪类元素设置鼠标悬停效果,用rgba元素实现透明效果