前端特效-HTML+CSS - 左側滑動進入

實現的效果

左側滑動進入

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;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章