css实现网格图片悬浮放大效果代码
代码语言:html
所属分类:图片放大
代码描述:css实现网格图片悬浮放大效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> .gallery { --s: 200px; /* control the size */ --g: 8px; /* control the gap */ display: grid; grid: auto-flow var(--s)/repeat(2,var(--s)); gap: var(--g); } .gallery > img { width: 100%; aspect-ratio: 1; cursor: pointer; filter: grayscale(); z-index: 0; transition: .25s,z-index 0s .25s; } .gallery > img:hover { width: calc(200% + var(--g)); filter: grayscale(0); z-index: 1; --_c: 50%; transition: .4s,z-index 0s; } .gallery > img:nth-child(1){ clip-path: circle(var(--_c,65% at 70% 70%)); place-self: start; } .gallery > img:nth-child(2){ clip-path: circle(var(--_c,65% at 30% 70%)); place-self: start end; } .gallery > img:nth-child(3){ clip-path: circle(var(--_c,65% at 70% 30%)); place-self: end start; } .gallery > img:nth-child(4){ clip-path: circle(var(--_c,65% at 30% 30%)); place-self: end; } body .........完整代码请登录后点击上方下载按钮下载查看
网友评论0