js+css实现图片相册点击放大切换效果代码
代码语言:html
所属分类:画廊相册
代码描述:js+css实现图片相册点击放大切换效果代码,纯原生css与js代码实现,按esc退出。
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/all.6.0.css"> <style> * { padding: 0; margin: 0; box-sizing: border-box; } body { height: 100vh; background-color: #dadada; display: flex; } .wrapper { width: 1200px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; margin: auto; } .image { width: 22%; height: 200px; overflow: hidden; margin: 10px; cursor: pointer; border-radius: 4px; } .image:hover img { transform: scale(1.2); } img { width: 100%; height: 100%; object-fit: cover; object-position: center; transition: 0.25s; } .gallery { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.8); z-index: 1; display: flex; opacity: 0; pointer-events: none; transform: scale(0.8); transition: 0.25s; } .gallery.show { opacity: 1; pointer-events: auto; transform: scale(1); } .gallery-inner { width: 70%; height: 70%; margin: auto; } .control { position: absolute; color: rgba(255, 255, 255, 0.8); font-size: 50px; top: 50%; transform: translateY(-50%); cursor: pointer; } .prev { left: 15px; } .next { right: 15px; } .close { color: white; font-size: 35px; position: absolute; top: 15px; right: 25px; cursor: pointer; } .hide { display: none; } </style> </head> <body> <div class="wrapper"> <div class="image"> <img src="//repo.bfw.wiki/bfwrepo/image/647d837864e37.png" alt="" /> </div> <div class="image"> <img src="//repo.bfw.wiki/bfwrepo/image/647d8364a5432.png" alt="" /> </div> <div class="image"> <img src="//repo.bfw.wiki/bfwrepo/image/647d835250232.png" alt="" /> </div> <div class="image"> <img src="//repo.bfw.wiki/bfwrepo/image/647d837864e37.png" alt="" /> </div> <div class="image"> <img src="//repo.bfw.wiki/bfwrepo/image/647d8364a5432.png" alt="" /> </div> <.........完整代码请登录后点击上方下载按钮下载查看
网友评论0