/* CSS3 动画示例代码 */
/* 定义关键帧动画 */
@keyframes example {
0% { background-color: red; left: 0px; top: 0px; }
25% { background-color: yellow; left: 200px; top: 0px; }
50% { background-color: blue; left: 200px; top: 200px; }
75% { background-color: green; left: 0px; top: 200px; }
100% { background-color: red; left: 0px; top: 0px; }
}
/* 应用动画到元素 */
div {
width: 100px;
height: 100px;
position: relative;
background-color: red;
animation-name: example;
animation-duration: 4s;
animation-iteration-count: infinite;
}
@keyframes example
:定义了一个名为 example
的关键帧动画,描述了元素在不同时间点的状态变化。这里设置了背景颜色和位置的变化。div
样式:将动画应用到一个 div
元素上,设置了宽度、高度、位置和初始背景颜色。animation-name
:指定了要应用的动画名称为 example
。animation-duration
:设置动画的持续时间为 4 秒。animation-iteration-count
:设置动画无限循环。这个例子展示了如何使用 CSS3 创建一个简单的动画效果。
上一篇:css线性渐变
下一篇:css 字体倾斜
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站