实现的效果
html部分
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>左侧滑动进入</title>
<link rel="stylesheet" href="./css/index.css">
</head>
<body>
<div class="post">
<img src="http://img2.imgtn.bdimg.com/it/u=1688631197,3554659657&fm=26&gp=0.jpg" alt="">
<div class="post-s">
<h1>Title</h1>
</div>
</div>
</body>
</html>
css部分
body {
background: #fff8dc;
margin: 0;
padding: 0;
}
.post {
width: 600px;
height: 400px;
position: relative;
cursor: pointer;
}
.post:hover .post-s {
width: 600px;
}
.post img {
display: block;
width: 600px;
height: 400px;
}
.post-s {
width: 0px;
height: 400px;
background: hsla(0,100%,50%,0.3);
position: absolute;
top: 0;
display: flex;
justify-content: center;
overflow: hidden;
transition: 0.7s ease;
}
.post-s h1 {
color: #fff;
font-size: 50px;
display: flex;
justify-content: center;
align-items: center;
border: 6px solid #fff;
padding: 0 30px;
}