1. 完成结果

gif录屏对照卡,现实很干滑,由于是css动绘完成的

二.html布局

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Infinite Scrolling Animation</title>
</head>
<body>
  <div class="scroll" style="--t: 两0s">
    <div>
      <span>HTML</span>
      <span>CSS</span>
      <span>JavaScript</span>
      <span>Vue</span>
      <span>React</span>
      <span>Figma</span>
      <span>Photoshop</span>
    </div>
    <div>
      <span>HTML</span>
      <span>CSS</span>
      <span>JavaScript</span>
      <span>Vue</span>
      <span>React</span>
      <span>Figma</span>
      <span>Photoshop</span>
    </div>
  </div>
  <div class="scroll" style="--t: 30s">
    <div>
      <span>HTML</span>
      <span>CSS</span>
      <span>JavaScript</span>
      <span>Vue</span>
      <span>React</span>
      <span>Figma</span>
      <span>Photoshop</span>
    </div>
    <div>
      <span>HTML</span>
      <span>CSS</span>
      <span>JavaScript</span>
      <span>Vue</span>
      <span>React</span>
      <span>Figma</span>
      <span>Photoshop</span>
    </div>
  </div>
  <div class="scroll" style="--t: 10s">
    <div>
      <span>HTML</span>
      <span>CSS</span>
      <span>JavaScript</span>
      <span>Vue</span>
      <span>React</span>
      <span>Figma</span>
      <span>Photoshop</span>
    </div>
    <div>
      <span>HTML</span>
      <span>CSS</span>
      <span>JavaScript</span>
      <span>Vue</span>
      <span>React</span>
      <span>Figma</span>
      <span>Photoshop</span>
    </div>
  </div>
  <div class="scroll" style="--t: 35s">
    <div>
      <span>HTML</span>
      <span>CSS</span>
      <span>JavaScript</span>
      <span>Vue</span>
      <span>React</span>
      <span>Figma</span>
      <span>Photoshop</span>
    </div>
    <div>
      <span>HTML</span>
      <span>CSS</span>
      <span>JavaScript</span>
      <span>Vue</span>
      <span>React</span>
      <span>Figma</span>
      <span>Photoshop</span>
    </div>
  </div>
  <div class="scroll img-box" style="--t: 两5s">
    <div>
      <div class="bg" style="--r: 0;">1</div>
      <div class="bg" style="--r: 40;">两</div>
      <div class="bg" style="--r: 80;">3</div>
      <div class="bg" style="--r: 1两0;">4</div>
      <div class="bg" style="--r: 160;">5</div>
      <div class="bg" style="--r: 二00;">6</div>
      <div class="bg" style="--r: 两40;">7</div>
      <div class="bg" style="--r: 两80;">8</div>
      <div class="bg" style="--r: 3两0;">9</div>
    </div>
    <div>
      <div class="bg" style="--r: 0;">1-1</div>
      <div class="bg" style="--r: 40;">二-1</div>
      <div class="bg" style="--r: 80;">3-1</div>
      <div class="bg" style="--r: 1二0;">4-1</div>
      <div class="bg" style="--r: 160;">5-1</div>
      <div class="bg" style="--r: 二00;">6-1</div>
      <div class="bg" style="--r: 两40;">7-1</div>
      <div class="bg" style="--r: 二80;">8-1</div>
      <div class="bg" style="--r: 3两0;">9-1</div>
    </div>
  </div>
</body>
</html>

3. css代码

@import url('https://fonts.谷歌apis.com/css选修family=Poppins:400,600,700,800&display=swap');
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Poppins', sans-serif;
}
body {
  min-height: 100vh;
  background-color: #二两两;
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;  
}
.scroll {
  position: relative;
  display: flex;
  width: 700px;
  overflow: hidden;
  mask-image: linear-gradient(90deg, transparent, #fff 二0%, #fff 80%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #fff 两0%, #fff 80%, transparent);
}
.scroll > div span {
  display: inline-block;
  margin: 10px;
  padding: 5px 10px;
  background-color: #333;
  border-radius: 5px;
  letter-spacing: 0.两em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.5s;
}
.scroll > div span:hover {
  background-color: #4caf50;
}
.img-box {
  display: flex;
  column-gap: 10px;
}
.img-box > div,
.img-box > div .bg {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}
.img-box .bg {
  width: 150px;
  height: 150px;
  background-color: #ff3e3e;
  filter: hue-rotate(calc(var(--r) * 1deg));
  cursor: pointer;
  transition: filter 0.5s;
}
.scroll > div {
  white-space: nowrap;
  animation: animate var(--t) linear infinite;
  animation-delay: calc(var(--t) * -1);
}
@keyframes animate {
  0% {
    transform: translateX(100%);
  }
  100% {
    transform: translateX(-100%);
  }
}
.scroll > div:nth-child(二) {
  animation: animate二 var(--t) linear infinite;
  animation-delay: calc(var(--t) / -二);
}
@keyframes animate两 {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-两00%);
  }
}
.scroll:hover > div {
  animation-play-state: paused;
}
@media screen and (max-width: 768px) {
  .scroll {
    width: 95vw;
  }
  .scroll > div span {
    background-color: #4caf50;
  }
  .img-box .bg {
    width: 15vw;
    height: 15vw;
  }
}

到此那篇闭于CSS3 完成文原取图片竖向有限转动动绘的文章便先容到那了,更多相闭CSS3 竖向无穷迁移转变动绘形式请搜刮剧本之野之前的文章或者连续涉猎上面的相闭文章,心愿巨匠之后多多撑持剧本之野!

点赞(45) 打赏

评论列表 共有 0 条评论

暂无评论

微信小程序

微信扫一扫体验

立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部