
实现原理是两个一样内容的div的transform css动画。
把背景图片改成透明可能更加好看一些没有css动画产生的裂缝。
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Title</title>
- <style>
- .view{
- display: block;
- height: 200px;
- width: 400px;
- border: 1px solid black;
- overflow: hidden;
- position: absolute;
- left: 400px;
- top: 200px;
- }
- .view>.page{
- animation: dot linear 3s infinite;
- /*border: 1px solid black;*/
- /*border-bottom: 1px solid black;*/
- height: auto;
- padding: 10px;
- color: white;
- box-sizing: border-box;
- background-image: linear-gradient(red,blue);width: 100%;
- }
- @keyframes dot {
- 0%{
- transform: translateY(0);
- }100%{
- transform: translateY(-100%);
- }
-
- }
- </style>
- </head>
- <body>
- <div class="view">
- <div class="page" style="">
- <h1>hello-word111</h1>
- <h1>hello-word222</h1>
- <h1>hello-word333</h1>
- <h1>hello-word444</h1>
- <h1>hello-word555</h1>
- </div>
- <div class="page" style="">
- <h1>hello-word111</h1>
- <h1>hello-word222</h1>
- <h1>hello-word333</h1>
- <h1>hello-word444</h1>
- <h1>hello-word555</h1>
- </div>
- </div>
- </body>
- </html>