<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>ihover</title>
<style>
.box{
width: 260px;
height: 260px;
margin: 0 auto;
position: relative;
overflow: hidden;
}
.img{
height: 100%;
width: 100%;
background: url(2.jpg) center center / cover no-repeat;
}
.text{
width: 100%;
height: 30%;
background-color:blue;
position: absolute;
top: 30%;
left: 0;
transform: rotate(-45deg) rotateX(90deg);
transition: 0.6s 0.9s ease-in-out;
line-height: 70%;
color: pink;
font-size: 26px;
text-align: center;
}
.img:after{
content: "";
position: absolute;
width: 100%;
height: 100%;
top:0;
left: 0;
background: rgba(0,0,0,0.6);
transform: translate(-149.99%) skew(-45deg);
transition: 0.9s ease-in-out;
}
.img:before{
content: "";
position: absolute;
width: 100%;
height: 100%;
top:0;
left: 0;
background: rgba(0,0,0,0.6);
transform: translate(149.9%) skew(-45deg);
transition: 0.9s ease-in-out;
}
.box:hover .img:after{
transform: translate(-49.9%) skew(-45deg);
}
.box:hover .img:before{
transform: translate(49.9%) skew(-45deg);
}
.box:hover .text{
transform: rotate(0deg) rotateX(0deg);
}
</style>
</head>
<body>
<div class="box">
<div class="img"></div>
<div class="text">welcome to 领哥
<p>领哥成就你的吃瓜梦想</p>
</div>
</div>
</body>
</html>
当鼠标划过时,半透明遮罩从两侧合上,再从中间缝隙中弹出带有文字的背景,成品展示如下图所示: