css实现grid九宫格布局图片悬浮放大效果代码
代码语言:html
所属分类:图片放大
代码描述:css实现grid九宫格布局图片悬浮放大效果代码
代码标签: css grid 九宫格 布局 图片 悬浮 放大
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> .gallery { --s: 150px; /* control the size */ --g: 10px; /* control the gap */ --f: 1.5; /* control the scale factor */ display: grid; gap: var(--g); width: calc(3*var(--s) + 2*var(--g)); aspect-ratio: 1; grid-template-columns: repeat(3,auto); } .gallery > img { width: 0; height: 0; min-height: 100%; min-width: 100%; object-fit: cover; cursor: pointer; filter: grayscale(80%); transition: .35s linear; } .gallery img:hover{ filter: grayscale(0); width: calc(var(--s)*var(--f)); height: calc(var(--s)*var(--f)); } body { margin: 0; min-height: 100vh; display: grid; place-content: center; background: #60c4ff; } </style> </head> <body > <div class="gallery"> <img src="//repo.bfw.wiki/bfwrepo/image/628427972e557.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_3000,h_300,/quality,q_90" alt="a forest after an apocalypse"> <img src="//repo.bfw.wiki/bfwrepo/image/628427c4ca32c.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_3000,h_300,/quality,q_90" alt="a waterfall and many rocks"> <img src="//repo.bfw.wiki/bfwrepo/image/62842812c0.........完整代码请登录后点击上方下载按钮下载查看
网友评论0