当前位置:   article > 正文

css 实现排行榜向上滚动

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
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/415337
推荐阅读
相关标签
  

闽ICP备14008679号