原生js实现图片放大镜效果
代码语言:html
所属分类:图片放大
代码描述:原生js实现图片放大镜效果
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
*,
*:after,
*:before {
box-sizing: border-box;
}
:root {
--viewfinder-scale: 4;
--viewfinder-size-scale: 0.5;
--size: 50;
}
body {
-webkit-box-align: center;
align-items: center;
display: -webkit-box;
display: flex;
min-height: 100vh;
-webkit-box-pack: center;
justify-content: center;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
flex-direction: column;
background: #8ce1f2;
}
h1 {
position: fixed;
right: 2rem;
bottom: 2rem;
margin: 0;
font-family: sans-serif;
color: #149cb8;
}
.zoomer {
box-shadow: 1vmin 1vmin 2vmin 1vmin #000;
height: calc(var(--size, 50) * 1vmin);
width: calc(var(--size, 50) * 1vmin);
position: relative;
}
.zoomer__img {
--color-one: #f2f2f2;
--color-two: #d9d9d9;
height: 100%;
width: 100%;
background: -webkit-gradient(linear, left top, left bottom, from(var(--color-one)), color-stop(var(--color-two)), to(var(--color-one)));
background: linear-gradient(var(--color-one), var(--color-two), var(--color-one));
}
.zoomer__img:not([src]) {
-webkit-animation: roll 1s infinite linear;
animation: roll 1s infinite linear;
}
.zoomer__img:not([src]) ~ .zoomer__viewfinder {
display: none;
}
.zoome.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0