css+div实现模糊照片变清晰拖拽对比效果代码

代码语言:html

所属分类:拖放

代码描述:css+div实现模糊照片变清晰拖拽对比效果代码

代码标签: css div 模糊 照片 清晰 拖拽 对比

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  



  
  
<style>
* {
  box-sizing: border-box;
}

:root {
  --aspect-ratio: 16 / 10;
  --min-width: 0.5rem;
  --frame: hsl(0 0% 80%);
}

body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background: black;
}

.panels {
  container-type: inline-size;
  width: 90vmin;
  aspect-ratio: var(--aspect-ratio);
  display: grid;
  grid-template-columns: auto 1fr;
  overflow: hidden;
  border: 2px solid var(--frame);
  border-radius: 4px;
  overflow: hidden;
}

.panel:first-of-type {
  position: relative;
}

.resizer {
  position: relative;
  top: 50%;
  right: 0;
  height: 48px;
  width: 400px;
  resize: horizontal;
  overflow: hidden;
  max-width: calc(100cqi - 1rem);
  min-width: 1rem;
  transform-origin: 100% 100%;
  scale: 4;
  translate: 24px -50%;
  background: green;
  z-index: 9999;
  -webkit-clip-path: inset(calc(100% - 12px) 0 0 calc(100% - 12px));
          clip-path: inset(calc(100% - 12px) 0 0 calc(100% - 12px));
  /* Important to hide it */
  opacity: 0;
}

/* Purely used to debug the handle hit spot */
/* .resizer::after {
  content: "";
  height: 12px;
  width: 12px;
  border-radius: 50%;
  background: red;
  position: absolute;
  bottom: 0;
  right: 0;
} */

.panel:first-of-type::before {
  content: "";
  position: absolute;
  width: 2px;
  top: 0;
  bottom: 0;
  right: 0;
  background: var(--frame);
  translate: 50% 0;
  pointer-events: none;
  z-index: 3;
  -webkit-mask: linear-gradient(white 0 calc(50% - 1rem), transparent calc(50% - 1rem) c.........完整代码请登录后点击上方下载按钮下载查看

网友评论0