zoukankan      html  css  js  c++  java
  • animation

    作者:zccst

    通过 CSS3,我们能够创建动画,这可以在许多网页中取代动画图片、Flash 动画以及 JavaScript。

    CSS3 @keyframes 规则

    如需在 CSS3 中创建动画,您需要学习 @keyframes 规则。

    @keyframes 规则用于创建动画。在 @keyframes 中规定某项 CSS 样式,就能创建由当前样式逐渐改为新样式的动画效果。

    什么是 CSS3 中的动画?

    动画是使元素从一种样式逐渐变化为另一种样式的效果。

    您可以改变任意多的样式任意多的次数。

    请用百分比来规定变化发生的时间,或用关键词 "from" 和 "to",等同于 0% 和 100%。

    0% 是动画的开始,100% 是动画的完成。

    为了得到最佳的浏览器支持,您应该始终定义 0% 和 100% 选择器。

    实例

    当动画为 25% 及 50% 时改变背景色,然后当动画 100% 完成时再次改变:

    @keyframes myfirst
    {
    0%   {background: red;}
    25%  {background: yellow;}
    50%  {background: blue;}
    100% {background: green;}
    }
    
    @-moz-keyframes myfirst /* Firefox */
    {
    0%   {background: red;}
    25%  {background: yellow;}
    50%  {background: blue;}
    100% {background: green;}
    }
    
    @-webkit-keyframes myfirst /* Safari 和 Chrome */
    {
    0%   {background: red;}
    25%  {background: yellow;}
    50%  {background: blue;}
    100% {background: green;}
    }
    
    @-o-keyframes myfirst /* Opera */
    {
    0%   {background: red;}
    25%  {background: yellow;}
    50%  {background: blue;}
    100% {background: green;}
    }
    <!DOCTYPE html>
    <html>
    <head>
    <style> 
    div
    {
    width:100px;
    height:100px;
    background:red;
    animation:myfirst 5s;
    -moz-animation:myfirst 5s; /* Firefox */
    -webkit-animation:myfirst 5s infinite; /* Safari and Chrome */
    -o-animation:myfirst 5s; /* Opera */
    }
    
    @keyframes myfirst
    {
    from {background:red;}
    to {background:yellow;}
    }
    
    @-moz-keyframes myfirst /* Firefox */
    {
    from {background:red;}
    to {background:yellow;}
    }
    
    @-webkit-keyframes myfirst /* Safari and Chrome */
    {
    from {background:red;}
    to {background:yellow;}
    }
    
    @-o-keyframes myfirst /* Opera */
    {
    from {background:red;}
    to {background:yellow;}
    }
    </style>
    </head>
    <body>
    
    <div></div>
    
    <p><b>注释:</b>本例在 Internet Explorer 中无效。</p>
    
    </body>
    </html>
  • 相关阅读:
    apache2三种模式及切换到event模式
    MySQL添加用户、创建数据库、分配权限
    ExcelHelper导出
    C#中将错误写进日志文件
    k3 cloud金蝶云参数设置云之家集成,提示无法推送企业消息
    k3 cloud中用视图类型来展示数据
    k3 cloud python 插件实现点击对应的单据编号打开单据
    k3 cloud单据转换的表
    sql server查询某个表对应的触发器
    QPainter::begin: Paint device returned engine == 0, type: 3
  • 原文地址:https://www.cnblogs.com/zccst/p/3680854.html
Copyright © 2011-2022 走看看