zoukankan      html  css  js  c++  java
  • CSS3 动画animation

    CSS3 动画属性animation

    语法:animation: name duration timing-function delay iteration-count direction;

    下面的表格列出了 @keyframes 规则和所有动画属性:

    属性描述CSS
    @keyframes 规定动画。 3
    animation 所有动画属性的简写属性,除了 animation-play-state 属性。 3
    animation-name 规定 @keyframes 动画的名称。 3
    animation-duration 规定动画完成一个周期所花费的秒或毫秒。默认是 0。 3
    animation-timing-function 规定动画的速度曲线。默认是 "ease"。 3
    animation-delay 规定动画何时开始。默认是 0。 3
    animation-iteration-count 规定动画被播放的次数。默认是 1。 3
    animation-direction 规定动画是否在下一周期逆向地播放。默认是 "normal"。 3
    animation-play-state 规定动画是否正在运行或暂停。默认是 "running"。 3
    animation-fill-mode 规定对象动画时间之外的状态。 3

    在 @keyframes 中创建动画时,请把它捆绑到某个选择器,否则不会产生动画效果。

    通过规定至少以下两项 CSS3 动画属性,即可将动画绑定到选择器:(infinite:无限循环)

    • 规定动画的名称
    • 规定动画的时长

    eg:

    div
    {
    animation: myfirst 5s;
    -moz-animation: myfirst 5s;	/* Firefox */
    -webkit-animation: myfirst 5s;	/* Safari 和 Chrome */
    -o-animation: myfirst 5s;	/* Opera */
    }

    什么是 CSS3 中的动画?

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

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

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

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

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

    eg:

    1.html

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>animation</title>
        <link rel="stylesheet" href="style/animation.css"/>
        <link rel="stylesheet" href="style/animation-color.css"/>
    </head>
    <body>
    <div class="animation"></div>
    <div class="animation-color"></div>
    </body>
    </html>

    2.css3 移动

    .animation{
        width: 100px;
        height: 100px;
        background-color: #2b81e2;
        position:relative;
        animation: move 6s infinite;
        -webkit-animation: move 6s infinite;
    }
    
    @keyframes move {
        from {
            left: 0;
            top: 0;
        }
        to{
            left: 300px;
            top: 300px;
        }
    }
    
    @-webkit-keyframes move {
        from {
            left: 0;
            top: 0;
        }
        to{
            left: 300px;
            top: 300px;
        }
    }

    3.css3 变色

    .animation-color{
        width: 100px;
        height: 100px;
        background-color: #66e229;
        animation: moveColor 5s infinite;
        -webkit-animation: moveColor 5s infinite;
    }
    
    @keyframes moveColor {
        from{
            background-color: #66e229;
        }
        to{
            background-color: #9fa8ef;
        }
    }
    
    @-webkit-keyframes moveColor {
        from{
            background-color: #66e229;
        }
        to{
            background-color: #9fa8ef;
        }
    }

    4.效果

     图一:

     图二:

     

     图三:

  • 相关阅读:
    illegal line end in String Iiteral错误
    mavem的tomcat插件热加载
    解决IntelliJ IDEA启动缓慢
    进行JDBC连接时增加以下代码:
    基于Reflect将List泛型数据源转换为Json字符串
    数据库还原至指定时间节点
    EF关系配置之N:N关系
    EF关系配置之1:N
    EF+Lambda查询性能测试
    EntityFramework基础框架搭建
  • 原文地址:https://www.cnblogs.com/Michelle20180227/p/8680991.html
Copyright © 2011-2022 走看看