css 实现排行榜向上滚动

使用动画实现无线向上滚动

复制一层dom,使用动画向上滚动,鼠标hover的时候暂停动画

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>

  <style>



* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Poppins', sans-serif;
}

body {
  min-height: 100vh;
  background-color: #222;
  color: #fff;

  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;  
}

.scroll {
  display: flex;
  width: 700px;
  overflow: hidden;
  mask-image: linear-gradient(90deg, transparent, #fff 20%, #fff 80%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #fff 20%, #fff 80%, transparent);
}




.scroll > div {
  white-space: nowrap;
  animation: animate var(--t) linear infinite;
  animation-delay: calc(var(--t) * -1);
  text-align: center;
  
}
.scroll>div>div {
    width: 300px;
    padding: 20px;
    background-color: cy;
}
@keyframes animate {
  0% {
    transform: translateY(100%);
  }

  100% {
    transform: translateY(-100%);
  }
}

.scroll > div:nth-child(2) {
  animation: animate2 var(--t) linear infinite;
  animation-delay: calc(var(--t) / -2);

}
.scroll > div:nth-child(2) div {
  /* background-color: red; */
  
}
@keyframes animate2 {
  0% {
    transform: translate(-100%,100%);
  }

  100% {
    transform: translate(-100%,-100%);
  }
}

.scroll:hover > div {
  animation-play-state: paused;
}





  </style>
</head>

<body>
  <div class="scroll" style="--t: 20s">
    <div>
      <div>HTML</div>
      <div>CSS</div>
      <div>JavaScript</div>
      <div>Vue</div>
      <div>React</div>
      <div>Figma</div>
      <div>Photoshop</div>
      <div>Photoshop2</div>
    </div>

    <div>
      <div>HTML</div>
      <div>CSS</div>
      <div>JavaScript</div>
      <div>Vue</div>
      <div>React</div>
      <div>Figma</div>
      <div>Photoshop</div>
      <div>Photoshop2</div>
    </div>
  </div>

  

  
</body>

</html>
相关推荐
spionbo21 分钟前
Vue 表情包输入组件实现代码及完整开发流程解析
前端·javascript·面试
全宝21 分钟前
✏️Canvas实现环形文字
前端·javascript·canvas
lyc23333321 分钟前
鸿蒙Core File Kit:极简文件管理指南📁
前端
我这里是好的呀22 分钟前
全栈开发个人博客12.嵌套评论设计
前端·全栈
我这里是好的呀23 分钟前
全栈开发个人博客13.AI聊天设计
前端·全栈
金金金__23 分钟前
Element-Plus:popconfirm与tooltip一起使用不生效?
前端·vue.js·element
lyc23333324 分钟前
小L带你看鸿蒙应用升级的数据迁移适配📱
前端
用户268128510666930 分钟前
react-pdf(pdfjs-dist)如何兼容老浏览器(chrome 49)
前端
阿怼丶30 分钟前
🚀 如何在内网中运行 Cesium?基于 NestJS 构建离线地形与影像服务
前端·gis