CSS3 - 动画效果

CSS3 - 动画效果 首页 / CSS入门教程 / CSS3 - 动画效果

CSS3 可以创建动画,它可以取代许多网页动画图像、Flash 动画和 JavaScript 实现的效果。

@keyframes 规则

关键帧将控制CSS3中的中间动画步骤。

带有左动画的关键帧

@keyframes animation {
   from {background-color: pink;}
   to {background-color: green;}
}
div {
   width: 100px;
   height: 100px;
   background-color: red;
   animation-name: animation;
   animation-duration: 5s;
}

上面的示例使用关键帧语法显示了动画的高度,宽度,颜色,名称和持续时间。

左移动画示例

<html>
   <head>
      <style type="text/css">
         h1 {
            -moz-animation-duration: 3s;
            -webkit-animation-duration: 3s;
            -moz-animation-name: slidein;
            -webkit-animation-name: slidein;
         }
         @-moz-keyframes slidein {
            from {
               margin-left:100%;
               width:300%
            }
            to {
               margin-left:0%;
               width:100%;
            }
         }
         @-webkit-keyframes slidein {
            from {
               margin-left:100%;
               width:300%
            }
            to {
               margin-left:0%;
               width:100%;
            }
         }
      </style>
   </head>

   <body>
      <h1>Tutorials Point</h1>
      <p>this is an example of moving left animation .</p>
      <button onclick="myFunction()">Reload page</button>
      <script>
         function myFunction() {
            location.reload();
         }
      </script>
   </body>
</html>

它将产生以下输出-

无涯教程网

链接:https://www.learnfk.comhttps://www.learnfk.com/css/css3-animation.html

来源:LearnFk无涯教程网

使用关键帧向左移动动画

<html>
   <head>
      <style type="text/css">
         h1 {
            -moz-animation-duration: 3s;
            -webkit-animation-duration: 3s;
            -moz-animation-name: slidein;
            -webkit-animation-name: slidein;
         }
         @-moz-keyframes slidein {
            from {
               margin-left:100%;
               width:300%
            }
            75% {
               font-size:300%;
               margin-left:25%;
               width:150%;
            }
            to {
               margin-left:0%;
               width:100%;
            }
         }
         @-webkit-keyframes slidein {
            from {
               margin-left:100%;
               width:300%
            }
            75% {
               font-size:300%;
               margin-left:25%;
               width:150%;
            }
            to {
               margin-left:0%;
               width:100%;
            }
         }
      </style>
   </head>

   <body>
      <h1>Tutorials Point</h1>
      
      <p>This is an example of animation left with an extra keyframe 
         to make text changes.</p>
      <button onclick="myFunction()">Reload page</button>
      <script>
         function myFunction() {
            location.reload();
         }
      </script>
   </body>
</html>

它将产生以下输出-

无涯教程网

链接:https://www.learnfk.comhttps://www.learnfk.com/css/css3-animation.html

来源:LearnFk无涯教程网

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

DevOps实战笔记 -〔石雪峰〕

小马哥讲Spring核心编程思想 -〔小马哥〕

TensorFlow 2项目进阶实战 -〔彭靖田〕

MySQL 必知必会 -〔朱晓峰〕

Spark性能调优实战 -〔吴磊〕

陶辉的网络协议集训班02期 -〔陶辉〕

性能优化高手课 -〔尉刚强〕

说透区块链 -〔自游〕

Web漏洞挖掘实战 -〔王昊天〕

好记忆不如烂笔头。留下您的足迹吧 :)