div+css通过has实现相册图片聚焦缩放效果代码

代码语言:html

所属分类:画廊相册

代码描述:div+css通过has实现相册图片聚焦缩放效果代码

代码标签: div css has 相册 图片 聚焦 缩放

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

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

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

  
  
<style>
body {
  padding: 2rem;
  background: #060f13;
}

.image-gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  max-width: 50rem;
  margin-inline: auto;
}

.image-gallery > img {
  width: 100%;
  aspect-ratio: 1/1;
  -o-object-fit: cover;
     object-fit: cover;
  transition: scale 350ms ease, opacity 350ms linear;
}

.image-gallery:has(img:hover) img:not(:hover) {
  scale: 0.8;
  opacity: 0.7;
}
</style>

  
</head>

<body translate="no">
  <div class="image-gallery">
  <img src='//repo.bfw.wiki/bfwrepo/image/64250fbe76676.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_300,h_200,/quality,q_90' alt=''>
  <img src='//repo.bfw.wiki/bfwrepo/image/643d48964ce59.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_300,h_200,/quality,q_90' alt=''>
  <img src='//repo.bfw.wiki/bfwrepo/image/6428d11281e1a.png?x-oss-process=image/auto-orient.........完整代码请登录后点击上方下载按钮下载查看

网友评论0