1、animation属性
1.1、animation 属性是一个简写属性,用于设置六个动画属性
animation: name duration timing-function delay iteration-count direction;
animation-name 属性为 @keyframes 动画规定名称
animation-duration 属性定义动画完成一个周期所需要的时间,以秒或毫秒计。
animation-timing-function 规定动画的速度曲线。
animation-delay 属性定义动画何时开始
animation-iteration-count 属性定义动画的播放次数。
animation-direction 属性定义是否应该轮流反向播放动画。
1.2、暂停动画
animation-play-state: paused|running;
animation-play-state:paused; 指定暂停动画
animation-play-state:running; 指定正在运行的动画
2、无限滚动实现
<template>
<div class="container">
<div class="scroll_box">
<ul>
<li v-for="index in 6" :key="index">{{index}}</li>
</ul>
<ul>
<li>1</li>
</ul>
</div>
</div>
</template>
<style scoped lang="scss">
.container {
.scroll_box {
width: 200px;
height: 200px;
overflow: hidden;
display: flex;
margin: auto;
border: 2px solid blue;
ul {
display: flex;
padding: 0;
margin: 0;
position: relative;
width: 1200px;
animation: myScroll 5s linear infinite;
li {
list-style: none;
width: 200px;
height: 200px;
text-align: center;
line-height: 200px;
font-size: 40px;
color: red;
border: 1px solid red;
box-sizing: border-box;
background: #1cdf27;
}
}
&:hover {
ul {
animation-play-state: paused;
}
}
@keyframes myScroll {
from {
left: 0px;
}
to {
left: -1200px;
}
}
}
}
</style>
3、效果展示
无限滚动