网站首页 > 知识剖析 正文
效果图:
如果没有animation-direction: alternate;属性的话, 那么每次完成动画帧, 就会立刻恢复到起始位置, 中间没有缓冲过程, 看起来就很生硬
- 所有代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
body {
display: flex;
}
.ball {
width: 100px;
height: 100px;
background: orange;
border-radius: 50%;
animation: ball 2s infinite;
margin-left: 100px;
text-align: center;
line-height: 100px;
}
.ball2 {
/* 属性定义是否循环交替"反向"播放动画。 如果动画被设置为只播放一次,该属性将不起作用。*/
animation-direction: alternate;
}
@keyframes ball {
to {
transform: translateY(200px);
}
}
</style>
</head>
<body>
<div class="ball ball1">无</div>
<div class="ball ball2">有</div>
</body>
</html>
animation-direction属性
normal | 默认值。动画按正常播放。 |
reverse | 动画反向播放。 |
alternate | 动画在奇数次(1、3、5...)正向播放,在偶数次(2、4、6...)反向播放。 |
alternate-reverse | 动画在奇数次(1、3、5...)反向播放,在偶数次(2、4、6...)正向播放。 |
猜你喜欢
- 2024-11-08 几个纯CSS实现的loading动画 css loading动画
- 2024-11-08 css3中动画animation中的steps()函数
- 2024-11-08 居然可以通过动画快速学习 css 要运用css动画需要运用什么规则
- 2024-11-08 现代CSS:纯 CSS 实现飘雪动画效果
- 2024-11-08 超干货 CSS3/SVG Loading动画集合
- 2024-11-08 CSS 动画分类 css动画代码大全
- 2024-11-08 详解CSS3中的transition:平滑过渡与动画效果
- 2024-11-08 30种CSS3动画特效按钮 css3动画教程
- 2024-11-08 现代CSS:纯 CSS 实现路径动画 css url 路径
- 2024-11-08 前端神器:超全的css加载动画 #前端培训
- 最近发表
- 标签列表
-
- xml (46)
- css animation (57)
- array_slice (60)
- htmlspecialchars (54)
- position: absolute (54)
- datediff函数 (47)
- array_pop (49)
- jsmap (52)
- toggleclass (43)
- console.time (63)
- .sql (41)
- ahref (40)
- js json.parse (59)
- html复选框 (60)
- css 透明 (44)
- css 颜色 (47)
- php replace (41)
- css nth-child (48)
- min-height (40)
- xml schema (44)
- css 最后一个元素 (46)
- location.origin (44)
- table border (49)
- html tr (40)
- video controls (49)