HTML CSS js 实现照片册悬停效果cid1038-网页前端设计
index.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>creative hover effect</title> <style> .container{ display: flex; width: 100%; padding: 4% 2%; box-sizing: border-box; height: 100vh; } .box{ flex: 1; overflow: hidden; transition: 0.5s; margin: 0 2%; box-shadow: 0 20px 30px rgba(0,0,0,0.1); line-height: 0; } .box > img{ width: 200%; height: calc(100% - 10vh); object-fit: cover; transition: 0.5s; } .box > span{ font-size: 3vh; display: block; text-align: center; height: 10vh; line-height: 2.5; font-family: tahoma; color: #333; text-transform: uppercase; } .box:hover{ flex: 1 1 50%; } .box:hover > img{ width: 100%; height: 100%; } </style> </head> <body> <div class="container"> <div class="box"> <img src="h1.JPG" alt=""> <span>css</span> </div> <div class="box"> <img src="h2.JPG" alt=""> <span>creative</span> </div> <div class="box"> <img src="h3.JPG" alt=""> <span>hover</span> </div> <div class="box"> <img src="girl-1561989_1920.jpg" alt=""> <span>hover</span> </div> </div> </body> </html>
?在线演示?
