avatar

目录
css3动画之背景无缝滚动

示例

(1) 背景来自jq22:http://www.jq22.com/demo/html5bg20151116/
(2) 动画来自:https://segmentfault.com/a/1190000003721884

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
<template>
<div class="body">
<div class="page">
<div class="page_box">
<ul class="box item1">
<li>li>
ul>
<ul class="box item2">
<li>li>
ul>
div>
<div class="title">背景无缝左右滚动div>
div>
div>
template>
<style lang="less" scoped>
/*核心css*/
@keyframes moveup {
0% {
transform: translateX(0);
}
100% {
transform: translateX(-100%);
}
}
/*样式*/
.page {
margin-top: 200px;
height: 100vh;
overflow: hidden;
position: relative;
.title {
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
font-size: 48px;
color: rgba(255, 255, 255, 0.8);
font-weight: 600;
}
.page_box {
width: 200vw;
.box {
animation: moveup 20s linear infinite;
margin: 0;
display: inline-block;
float: left;
li {
background: url(https://pic.downk.cc/item/5e6af516e83c3a1e3a620715.jpg)
no-repeat center center;
width: 100vw;
height: 100vh;
background-size: cover;
list-style: none;
}
}
}
}
style>
文章作者: 会吃鱼的猫
文章链接: https://lovecatdog.github.io/2020/03/13/css3%E5%8A%A8%E7%94%BB%E4%B9%8B%E8%83%8C%E6%99%AF%E6%97%A0%E7%BC%9D%E6%BB%9A%E5%8A%A8/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 LoveCatDog
打赏
  • 微信
    微信
  • 支付宝
    支付宝

评论
简体中文