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>
相关推荐
专注VB编程开发20年13 分钟前
Excel软件界面美化-WEBUI-webbrowser内核
css·excel·vba·webui
じòぴé南冸じょうげん13 分钟前
若依框架favicon.ico缓存更新问题解决方案:本地生效但线上未更新
前端·javascript·前端框架·html
狮子座的男孩17 分钟前
js基础高级:01、数据类型(typeof、instanceof、===的使用)、数据与变量与内存(定义、赋值与内存关系、引用变量赋值、js调函数传参)
前端·javascript·经验分享·数据类型·数据与变量与内存·赋值与内存关系·引用变量赋值
Cyclo-3 小时前
PDFJS 在React中的引入 使用组件打开文件流PDF
前端·react.js·pdf
椒盐螺丝钉6 小时前
Vue Router应用:组件跳转
前端·javascript·vue.js
顾安r6 小时前
11.20 开源APP
服务器·前端·javascript·python·css3
敲敲了个代码6 小时前
CSS 像素≠物理像素:0.5px 效果的核心密码是什么?
前端·javascript·css·学习·面试
少云清6 小时前
【软件测试】5_基础知识 _CSS
前端·css·tensorflow
倔强青铜三7 小时前
AI编程革命:React + shadcn/ui 将终结前端框架之战
前端·人工智能·ai编程
天外飞雨道沧桑7 小时前
前端开发 Cursor MCP 提效工具配置
前端·vscode·ai编程·开发工具·cursor