CSS动画是一种强大的技术,可以让网页元素以动态和有趣的方式展示。下面是一些CSS动画的基本概念和用法。
CSS动画基本概念
- 关键帧(Keyframes): 关键帧定义了动画从开始到结束的状态变化。
- 动画属性(Animation Properties): 指定动画的持续时间、动画曲线、迭代次数等。
- 触发动画(Trigger Animation): 使用
:hover
、:active
等伪类来触发动画。
CSS动画示例
以下是一个简单的CSS动画示例:
@keyframes example {
0% { background-color: red; width: 100px; height: 100px; }
50% { background-color: yellow; width: 200px; height: 200px; }
100% { background-color: green; width: 100px; height: 100px; }
}
.box {
animation-name: example;
animation-duration: 4s;
}
<div class="box"></div>
扩展阅读
想要了解更多关于CSS动画的知识,可以阅读本站的CSS动画教程。
CSS动画示例