Laravel  
laravel
文档
数据库
架构
入门
php技术
    
Laravelphp
laravel / php / java / vue / mysql / linux / python / javascript / html / css / c++ / c#

css动画效果

作者:妳明白莪還在等待嗎?   发布日期:2026-05-08   浏览:102

/* CSS 动画效果示例 */

/* 定义关键帧动画 */
@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; }
}

/* 应用动画到元素 */
#animate {
    width: 100px;
    height: 100px;
    position: relative;
    background-color: red;
    animation-name: example;
    animation-duration: 4s;
    animation-iteration-count: infinite;
}

解释说明:

  1. @keyframes example:定义了一个名为 example 的关键帧动画。每个百分比表示动画在该时间点的状态,从 0%100%
  2. #animate:选择器应用于一个 ID 为 animate 的元素,并设置了宽度、高度、位置和背景颜色。
  3. animation-name: example:指定应用的关键帧动画名称。
  4. animation-duration: 4s:设置动画的持续时间为 4 秒。
  5. animation-iteration-count: infinite:设置动画无限循环。

这个示例代码展示了一个简单的 CSS 动画,使一个方块在页面上移动并改变背景颜色。

上一篇:css 鼠标样式

下一篇:css 绝对定位

大家都在看

css好看的字体

css 红色

css 瀑布流布局grid

css盒子

css字体加粗怎么设置的

css三种引入方式

换行 css

css文字超长省略号

css图片铺满整个背景

css背景图铺满

Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3

Laravel 中文站