css+js实现自适应网格图片相册视觉差异滚动效果代码

代码语言:html

所属分类:视觉差异

代码描述:css+js实现自适应网格图片相册视觉差异滚动效果代码

代码标签: css js 自适应 网格 图片 相册 视觉 差异 滚动

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

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

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

  
  
<style>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.gallery-track {
  position: fixed;
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: 0.25rem;
  padding: 0.25rem;
  will-change: transform;
}

.card {
  height: 400px;
  overflow: hidden;

  & .card-image-wrapper {
    height: 135%;
    will-change: transform;

    & img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }
  }
}

@media (width < 800px) {
  .gallery-track {
    grid-template-columns: repeat(2,1fr);
  }
}

@media (width < 550px) {
  .gallery-track {
    grid-template-columns: repeat(1,1fr);
  }
}
</style>

  
  
  
</head>

<body translate="no">
  <main class='gallery'>
  <div class='gallery-track'>
    <div class='card'>
      <div class='card-image-wrapper'>
        <img src='//repo.bfw.wiki/random/400x400/景色'>
      </div>
    </div>
    <div class='card'>
      <div class='card-image-wrapper'>
        <img src='//repo.bfw.wiki/random/400x400/海洋'>
      </div>
    </div>
    <div class='card'>
      <div class='card-image-wrapper'>
        <img src='//repo.bfw.wiki/random/400x400/景色'>
      </div>
    </div>
    <div class='card'>
      <div class='card-image-wrapper'>
        <img src='//repo.bfw.wiki/random/400x400/日落'>
      </div>
    </div>
    <div class='card'>
      <div class='card-image-wrapper'>
        <img src='//repo.bfw.wiki/random/400x400/景色'>
      </div>
    </div>
    <div class='card'>
      <div class='card-image-wrapper'>
        <img src='//repo.bfw.wiki/random/400x400/日出'>
      </div>
    </div>
    <div class='card'>
      <div class='card-image-wrapper'>
        <img src='//repo.bfw.wiki/random/400x400/景色'>
      </div>
    </div>
    <div class='card'>
      <div class='card-image-wrapper'>
        <img src='//repo.bfw.wiki/random/400x400/夜景'>
      </div>
    </div>
    <div class='card'>
      <div class='card-image-wrapper'>
        <img src='//repo.bfw.wiki/random/400x400/景色'>
      </div>
    </div>
    <div class='card'>
      <div class='card-image-wrapper'>
        <img src='//repo.bfw.wiki/random/400x400/海洋'>
      </div>
    </div>
    <div class='card'>
      <div class='card-image-wrapper'>
        <img src='//repo.bfw.wiki/random/400x400/景色'>
      </div>
    </div>
    <div class='card'>
      <div class='card-image-wrapper'>
        <img src='//repo.bfw.wiki/random/400x400/夏季'>
      </div>
    </div>
    <div class='card'>
      <div class='card-image-wrapper'>
        <img src='//repo.bfw.wiki/random/400x400/景色'>
      </div>
    </div>
    <div class='card'>
      <div class='card-image-wrapper'>
        <img src='//repo.bfw.wiki/ran.........完整代码请登录后点击上方下载按钮下载查看

网友评论0