css实现图片filter拖动对比效果代码
代码语言:html
所属分类:其他
代码描述:css实现图片filter拖动对比效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> :root { --tra: all 0.5s ease 0s; } body { margin: 0; padding: 0; overflow: hidden; display: flex; justify-content: center; align-items: center; width: 100vw; height: 100vh; font-family: Arial, Helvetica, serif; background: radial-gradient(circle at 50% 0%, #000, #333); } body:before { content: "IMAGES FROM UNSPLASH.COM"; position: absolute; color: #fff0; left: 50%; transform: translateX(-50%); text-shadow: 0 1px 1px #333d, 0 -1px 1px #ffffff82; font-family: Arial, serif; font-size: 1.3vmin; margin-top: -86.5vmin; } body * { box-sizing: border-box; } .comparsion { width: 40vmin; height: 30vmin; position: relative; transform: scale(2.25); box-shadow: 0 0 0 1vmin #fff; } .comparsion > div { background: url(//repo.bfw.wiki/bfwrepo/image/646ee114955eb.png) no-repeat 0 0; background-size: cover; width: 100%; height: 100%; position: absolute; } .filtered { filter: sepia(0.9); } .comparsion > .original { width: calc(50% + 2px); resize: horizontal; overflow: hidden; max-width: calc(40vmin - 1.35vmin); border-right: 0.325vmin solid #fff8; } div::-webkit-resizer { background: linear-gradient(135deg, #fff0 0 1.5vmin, #fff 0 1.7vmin, #fff0 0 1.9vmin, #fff 0 2.1vmin, #fff0 0 2.3vmin, #fff 0 2.5vmin, #fff0 0 2.7vmin, #fff 0 100%); } label, a { position: absolute; margin-top: 88vmin; background: red; width: 5vmin; height: 5vmin; cursor: pointer; border-radius: 0.15vmin; margin-left: -7.5vmin; } label:hover { background: blue; } label + label { margin-left: 7.5vmin; } label + label + label { margin-left: 22.5vmin; } input { display: none; } input#grayscale:checked ~ .comparsion .filtered { filter: grayscale(1); } input#color:checked ~ .comparsion .filtered { filter: hue-rotate(45deg); } input#sepia:checked ~ label[for=sepia], input#grayscale:checked ~ label[for=grayscale], input#color:checked ~ label[for=color] { box-shadow: 0 0 0 0.45vmin #fff inset; cursor: default; } a { margin-left: -22.5vmin; background: #fff; } a:hover { background: #fff; } a:before { --ar: #282828; content: ""; position: absolute; width: 5vmin; height: 5vmin; border-radius: 100%; transform: rotate(0deg); background: rad.........完整代码请登录后点击上方下载按钮下载查看
网友评论0