原生js+css实现自适应图片列表相册滚动点击放大效果代码

代码语言:html

所属分类:图片放大

代码描述:原生js+css实现自适应图片列表相册滚动点击放大效果代码

代码标签: 原生 js css 自适应 图片 列表 相册 滚动 点击 放大

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

<!DOCTYPE html>
<html lang="en" >
<head>
  <meta charset="UTF-8">
<style>
    * {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.wrapper {
  height: 100vh;
  height: 100svh;
  display: grid;
  place-items: center;
  background-color: var(--overlay);
  transition: background-color 0.8s;
}

.marquee {
  display: grid;
  grid-template-columns: repeat(9,minmax(12vmin,1fr));
  width: 70%;
  overflow: hidden;
  mask-image: linear-gradient(
    to right,
    rgba(0,0,0,0),
    rgba(0,0,0,1) 10%,
    rgba(0,0,0,1) 90%,
    rgba(0,0,0,0)
  );

  & img {
    --time: 35s;
    position: relative;
    width: 105%;
    aspect-ratio: 1;
    grid-column: 1;
    grid-row: 1;
    object-fit: cover;
    cursor: pointer;
    left: calc(100% * 9);
    animation: marquee var(--time) linear infinite;

    &:nth-of-type(1) { animation-delay: calc((var(--time) / 9) * (9 - 1) * -1); }
    &:nth-of-type(2) { animation-delay: calc((var(--time) / 9) * (9 - 2) * -1); }
    &:nth-of-type(3) { animation-delay: calc((var(--time) / 9) * (9 - 3) * -1); }
    &:nth-of-type(4) { animation-delay: calc((var(--time) / 9) * (9 - 4) * -1); }
    &:nth-of-type(5) { animation-delay: calc((var(--time) / 9) * (9 - 5) * -1); }
    &:nth-of-type(6) { animation-delay: calc((var(--time) / 9) * (9 - 6) * -1); }
    &:nth-of-type(7) { animation-delay: calc((var(--time) / 9) * (9 - 7) * -1); }
    &:nth-of-type(8) { animation-delay: calc((var(--time) / 9) * (9 - 8) * -1); }
    &:nth-of-type(9) { animation-delay: calc((var(--time) / 9) * (9 - 9) * -1); }
  }
}

@keyframes marquee {
  to {
    left: -100%;
  }
}

dialog {
  border: none;
  outline: none;
  margin: auto;
  border-radius: 0.25rem;
  background-color: transparent;

  &::backdrop { display: none; }

  & img {
    width: min(800px,80vw);
    aspect-ratio: 16/9;
    object-fit: cover;
    display: block;
  }
}
</style>

</head>
<body>

<main class='wrapper'>
  <div class='marquee'>
    <img src='//repo.bfw.wiki/bfwrepo/image/5d65ea7d8bc8b.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_200,h_200,/quality,q_90' data-src='//repo.bfw.wiki/bfwrepo/image/5d65ea7d8bc8b.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_800,h_600,/quality,q_90'>
       <img src='//repo.bfw.wiki/bfwrepo/image/5d6539c1971b8.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_200,h_200,/quality,q_90' data-src='//repo.bfw.wiki/bfwrepo/image/5d6539c1971b8.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_800,h_600,/quality,q_90'>
    <img src='//repo.bfw.wiki/bfwrepo/image/5d65ea7d8bc8b.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_200,h_200,/quality,q_90' data-src='//repo.bfw.wiki/bfwrep.........完整代码请登录后点击上方下载按钮下载查看

网友评论0