div+css实现多张图片饱和度拖拽对比比较效果代码
代码语言:html
所属分类:拖放
代码描述:div+css实现多张图片饱和度拖拽对比比较效果代码,点击底部圆点切换照片。
代码标签: div cs 多张 图片 饱和度 拖拽 对比 比较
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> @charset "UTF-8"; /* ====== IMPORTS ====== */ @import url("https://fonts.googleapis.com/css2?family=Handlee&display=swap"); /* ====== GENERIC ELEMENTS/ COMPONENTS ====== */ * { /* silly little reset */ margin: 0; padding: 0; background: none; color: inherit; font: inherit; } body, main, section, figure, form { display: grid; } body { grid-template-rows: 100%; overflow-x: hidden; min-height: 100vh; background: #212121; color: #ededed; font: 400 clamp(.75em, 3.5vw, 1.5em)/1.5 handlee, cursive; } svg { position: fixed; } section, [type=range], figure { grid-area: 1/1; } main { box-sizing: border-box; grid-gap: 0.25em; grid-template-rows: 1fr 1lh; justify-self: center; padding: min(1.5em, 5vw); width: min(100%, 50em); min-height: 25em; filter: drop-shadow(2px 2px 5px #121212); } section { overflow: hidden; } figure { position: relative; grid-template-rows: 1fr 2lh; z-index: var(--j); translate: calc((var(--i) - var(--k))*100%); } figure[id=filtered] img { filter: url(#f); } img, [type=range] { height: calc(100% - 2lh); } img { position: absolute; width: 100%; object-fit: cover; clip-path: inset(0 0 0 calc(var(--j)*var(--val)*1%)); } figcaption { grid-row: 2; place-self: center end; } a { color: dodgerblue; } [type=range] { /* allow styling in WebKit browsers */ /* position of thumb vertical midline */ --pos: calc(1.5em + var(--val)/100*(100% - 3em)); /* ensure it's on top of figure siblings; without z-index, * its thumb shows up on top of the figure elements... * but its background is painted underneath 🙀 */ z-index: 1; /* extend beyond lateral edges of parent by a thumb radius */ margin: 0 -1.5em; /* vertical split line coincides with thumb vertical midline */ background: linear-gradient(90deg, #0000 calc(var(--pos) - .5*2px), currentcolor 0 calc(var(--pos) + .5*2px), #0000 0) 0 0/100% calc(50% - 1.5em) space; /* some kind of :hover/ :focus extra style */ filter: drop-shadow(1px 0 2px rgba(0, 0, 0, var(--hov, 1))); /* allow click through to images & right click context menu */ pointer-events: none; /* style thumb cross-browser */ } [type=range], [type=range]::-webkit-slider-thumb { appearance: none; } [type=range]::-webkit-slider-thumb { /* full area coverage gradient */ --full: linear-gradient(red 0 0); /* set explicitly as it's content-box in Firefox & * we want border & padding subtracted from dims */ box-sizing: border-box; /* highlight thumb boundary */ border: solid 2px currentcolo.........完整代码请登录后点击上方下载按钮下载查看
网友评论0