css 实现排行榜向上滚动

在这里插入图片描述

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

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

<!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>



相关推荐

  1. css实现跑马灯(电子屏滚动)效果

    2024-04-10 08:46:03       51 阅读
  2. css实现文字左右循环滚动播放效果

    2024-04-10 08:46:03       43 阅读
  3. css3实现无缝滚动,鼠标经过暂停

    2024-04-10 08:46:03       52 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-10 08:46:03       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-10 08:46:03       106 阅读
  3. 在Django里面运行非项目文件

    2024-04-10 08:46:03       87 阅读
  4. Python语言-面向对象

    2024-04-10 08:46:03       96 阅读

热门阅读

  1. 互联网人才现状分析

    2024-04-10 08:46:03       40 阅读
  2. android 源码环境配置

    2024-04-10 08:46:03       38 阅读