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

css动画

作者:发光男神   发布日期:2025-04-23   浏览:48

/* 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; }
}

/* 应用动画到元素 */
div {
  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. div:选择器选择了所有的 div 元素,并应用了动画效果。
  3. animation-name:指定了要使用的动画名称为 example
  4. animation-duration:设置动画的持续时间为 4 秒。
  5. animation-iteration-count:设置动画无限次循环。

这个例子中,一个 div 元素会在 4 秒内改变其背景颜色和位置,并且会无限次重复这个过程。

上一篇:postcss

下一篇:css字体加粗

大家都在看

css 红色

css文字超长省略号

css 渐变字体

css背景图片等比例缩放

css文字删除线

css 自定义滚动条

css flex gap

css上一个兄弟元素怎么找到

css文字超出隐藏变省略号鼠标上去展示完整

css文字不允许换行

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

Laravel 中文站