您的位置:新葡亰496net > 新葡亰官网 > 新葡亰496net:推荐介绍8款CSS3落到实处的动态特效

新葡亰496net:推荐介绍8款CSS3落到实处的动态特效

发布时间:2019-10-13 08:30编辑:新葡亰官网浏览(180)

    CSS技能:逐帧动画抖动应用方案

    2017/08/16 · CSS · 动画

    初稿出处: 坑坑洼洼实验室   

    笔者所在的前端团队首要从事活动端的H5页面开辟,而集体运用的适配方案是: viewport units rem。具体能够参见凹凸实验室的作品 – 应用视口单位落实适配布局 。

    作者最近(2017.08.12)接触到的位移端适配方案中,「利用视口单位贯彻适配布局」是最棒的方案。不过使用 rem 作为单位会遇见以下多少个困难:

    • 微观尺寸(20px左右)定位不准
    • 逐帧动画轻易有震憾

    首先个难点的平常性现身在 icon 绘制进程,能够接纳图片或者 svg-icon 消除那么些标题,笔者刚毅提出使用 svg-icon,具体理由能够惊羡:「拥抱Web设计新势头:SVG Coca Colas实施应用」。

    其次个难点小编譬释迦牟尼深入分析抖动的原由和查找技术方案。

    三个尖栗上手 CSS3 动画

    2017/05/10 · CSS · 2 评论 · CSS3, 动画

    正文作者: 伯乐在线 - 陈被单 。未经笔者许可,制止转发!
    应接参加伯乐在线 专栏撰稿人。

    新近乌烟瘴气的业务非常多,相当多文化都没赶趟总结,是时候计算总括,开启新的篇章~

    本篇小说不一一列举CSS3卡通的质量,若须求驾驭API,可前往MDN 。

    在开班栗子前,大家先补补基础知识。

    css3动画分类:

    • 补间动画 – 拥有连贯性的卡通片
    • 逐帧动画 – 使用steps过渡格局贯彻跳跃

    animation常用属性及形貌:

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

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

    1. timing-function属性:  

    • ease 规定慢速先导,然后变快,然后慢速甘休的对接效果。
    • ease-in 规定以慢速起初的联网效果。
    • ease-out 规定以慢速结束的连片效果。
    • ease-in-out 规定以慢速发轫和结束的衔接效果。
    • linear 动画原原本本的速度是毫发不爽的。
    • cubic-bezier(n,n,n,n) 在cubic-bezier函数中和谐的值,n取值为0~1
    • steps()

    2. delay属性:用于将动画片与其他动画片的施行机会错开,将动画落到差别的时间点。那性情子很好用~

    卡通原则:

    1. 一举手一投足平时有个惯性,所以要先快后有一个慢一点的反弹。
    2. 背景若选用三个轻松熠熠闪闪,错位闪烁

    配合JS使用

    slide.addEventListener("webkitAnimationEnd", function() { console.log('eeee') //动画甘休再调用 });

    1
    2
    3
    slide.addEventListener("webkitAnimationEnd", function() {
       console.log('eeee') //动画结束再调用
    });

    有一点点景况我们要求确认保障动画停止后再开展其他一些交互,可使用该事件监听。


    实战演习:

    设若大家须求贯彻三个那样总结的卡通片:

    新葡亰496net 1

    留神观看地点的动画,大家发掘,它能够由以下3部分构成:

    1. 上场动画——从右往左移动

    2. 反正循环移动

    3. 逐帧动画

    贯彻格局:

    使用3个dom元素,最外层dom完成进场动画,第二层dom完成左右平移,第三层dom落成逐帧动画。

    优点:调节和测量检验方便,节省时间。

    缺点:dom多。

    1. dom结构

    <div class="anima_entrance"> <div class="anima_move"> <div class="anima_sprite"></div> </div> </div>

    1
    2
    3
    4
    5
    <div class="anima_entrance">
        <div class="anima_move">
            <div class="anima_sprite"></div>
        </div>
    </div>

    2. 深入分析动画变成的日子轴:

    新葡亰496net 2

    上台动画持续0.6s,只播放二次,左右移动乃至逐帧动画持续2s,循环播放,代码如下:

    .anima_entrance { animation: anima_entrance .6s ease-in-out both; } .anima_move { animation: anima_move 2s linear .6s infinite both; } .anima_sprite { animation: anima_sprite 2s step-end .6s infinite both; }

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    .anima_entrance {
        animation: anima_entrance .6s ease-in-out both;
    }
     
    .anima_move {
        animation: anima_move 2s linear .6s infinite both;
    }
     
    .anima_sprite {
        animation: anima_sprite 2s step-end .6s infinite both;
    }

    3. 施用steps()实现逐帧动画:

    应用下边那张Pepsi-Cola图,通过退换background-position完结动画切换。

    新葡亰496net 3

    蹬蹬蹬,效果如上边所示,是或不是很失望

    新葡亰496net 4

    缘由:由于animation私下认可以ease形式接入,它会在各样关键帧之间插入补间动画,所以动画效果是连贯性的。此时得以选取steps()裁撤补间动画。

    贴二个图:

    新葡亰496net 5

    • steps(1,start): 动画一上马就跳到 100%直到这一帧(不是全体周期)结束   == step-start
    • steps(1,end): 保持 0% 的样式直到这一帧(不是整整周期)结束   == step-end

    随后,我们将timing-function改成 step-end,效果如下:

    animation: sprite 2s step-end .6s infinite both;

    1
    animation: sprite 2s step-end .6s infinite both;

    新葡亰496net 6

    出现想要的成效了哈~不错。

    完全的css代码如下:

    .anima_entrance { position: absolute; z-index: 3; top: 5.1rem; left: 4.05rem; width: 12.9rem; height: 19.1rem; -webkit-animation: anima_entrance .6s ease-in-out both; animation: anima_entrance .6s ease-in-out both; } .anima_move { width: 218px; height: 382px; position: absolute; z-index: 1; top: 0; left: 42px; -webkit-animation: anima_move 2s linear .6s infinite both; animation: anima_move 2s linear .6s infinite both; } .anima_sprite { width: 218px; height: 382px; background: url(demo.png) no-repeat 0 0; background-size: 25.8rem 19.1rem; -webkit-animation: anima_sprite 2s step-end .6s infinite both; animation: anima_sprite 2s step-end .6s infinite both; } @keyframes anima_entrance { 0% { -webkit-transform: translate3d(18.75rem, 0, 0); transform: translate3d(18.75rem, 0, 0); } 100% { -webkit-transform: translate3d(0, 0, 0); transform: translate3d(0, 0, 0); } } @keyframes anima_move { 0%, 16%, 42%, 74%, 100% { -webkit-transform: translate3d(0, 0, 0); transform: translate3d(0, 0, 0); } 29% { -webkit-transform: translate3d(-1rem, 0, 0); transform: translate3d(-1rem, 0, 0); } 87% { -webkit-transform: translate3d(1rem, 0, 0); transform: translate3d(1rem, 0, 0); } } @keyframes anima_sprite { 0%, 16%, 42%, 58%, 74%, 100% { background-position: -12.9rem 0; } 8%, 50%, 66% { background-position: 0 0; } }

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    .anima_entrance {
        position: absolute;
        z-index: 3;
        top: 5.1rem;
        left: 4.05rem;
        width: 12.9rem;
        height: 19.1rem;
        -webkit-animation: anima_entrance .6s ease-in-out both;
        animation: anima_entrance .6s ease-in-out both;
    }
     
    .anima_move {
        width: 218px;
        height: 382px;
        position: absolute;
        z-index: 1;
        top: 0;
        left: 42px;
        -webkit-animation: anima_move 2s linear .6s infinite both;
        animation: anima_move 2s linear .6s infinite both;
    }
     
    .anima_sprite {
        width: 218px;
        height: 382px;
        background: url(demo.png) no-repeat 0 0;
        background-size: 25.8rem 19.1rem;
        -webkit-animation: anima_sprite 2s step-end .6s infinite both;
        animation: anima_sprite 2s step-end .6s infinite both;
    }
     
    @keyframes anima_entrance {
        0% {
            -webkit-transform: translate3d(18.75rem, 0, 0);
            transform: translate3d(18.75rem, 0, 0);
        }
        100% {
            -webkit-transform: translate3d(0, 0, 0);
            transform: translate3d(0, 0, 0);
        }
    }
     
    @keyframes anima_move {
        0%, 16%, 42%, 74%, 100% {
            -webkit-transform: translate3d(0, 0, 0);
            transform: translate3d(0, 0, 0);
        }
        29% {
            -webkit-transform: translate3d(-1rem, 0, 0);
            transform: translate3d(-1rem, 0, 0);
        }
        87% {
            -webkit-transform: translate3d(1rem, 0, 0);
            transform: translate3d(1rem, 0, 0);
        }
    }
     
    @keyframes anima_sprite {
        0%, 16%, 42%, 58%, 74%, 100% {
            background-position: -12.9rem 0;
        }
        8%, 50%, 66% {
            background-position: 0 0;
        }
    }

    打赏协助小编写出越多好小说,谢谢!

    打赏小编

    思路相同的时候改换光滑度和圆形的分寸,Infiniti循环

    大家都知晓,在网页制作时选用CSS技艺,能够使得地对页面包车型客车布局、字体、颜色、背景和另外功效落到实处更为规范的主宰。只要对相应的代码做一些简易的更动,就足以转移同一页面包车型地铁例外界分,只怕页数不一致的网页的外观和格式。CSS3是CSS手艺的升迁版本,CSS3语言开垦是朝着模块化发展的。推荐7款CSS3达成的动态特效。希望对大家有着帮忙!

    新葡亰496net 7

    叁个共振的例证

    做三个8帧的逐帧动画,每帧的尺码为:360×540。

    JavaScript

    .steps_anim { position: absolute; width: 9rem; height: 13.5rem; background: url(//misc.aotu.io/leeenx/sprite/m.png) 0 0 no-repeat; background-size: 45rem 13.5rem; top: 50%; left: 50%; margin: -5.625rem 0 0 -5.625rem; animation: step 1.2s steps(5) infinite; } @keyframes step { 100% { background-position: -45rem; } }

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    .steps_anim {
      position: absolute;
      width: 9rem;
      height: 13.5rem;
      background: url(//misc.aotu.io/leeenx/sprite/m.png) 0 0 no-repeat;
      background-size: 45rem 13.5rem;
      top: 50%;
      left: 50%;
      margin: -5.625rem 0 0 -5.625rem;
      animation: step 1.2s steps(5) infinite;
    }
    @keyframes step {
      100% {
        background-position: -45rem;
      }
    }

    观测在主流(手提式有线电话机)分辨率下的播放情形:

    iPhone 6
    (375×667)
    iPhone 6
    (414×736)
    iPhone 5
    (320×568)
    Android
    (360×640)

    多种分辨率下,能够旁观除了 ip6 此外的二种分辨率都产生了震撼。ip6 不抖动的由来是适配方案是基本于 ip6 的分辨率订制的。)

    打赏扶持自身写出越来越多好小说,多谢!

    任选一种支付格局

    新葡亰496net 8 新葡亰496net 9

    1 赞 7 收藏 2 评论

    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文书档案</title>
    <style>
    @keyframes warn {
    0% {
    transform: scale(0);
    opacity: 0.0;
    }
    25% {
    transform: scale(0);
    opacity: 0.1;
    }
    50% {
    transform: scale(0.1);
    opacity: 0.3;
    }
    75% {
    transform: scale(0.5);
    opacity: 0.5;
    }
    100% {
    transform: scale(1);
    opacity: 0.0;
    }
    }
    .container {
    position: relative;
    border: 1px solid #000;
    background: #f55e55;
    }
    .part {
    position: relative;
    margin: 200px auto;
    width: 90px;
    height: 90px;
    background: #f55e55;
    }
    /* 发生动画(向外扩散变大)的圆圈 */
    .pulse-max {
    position: absolute;
    width: 90px;
    height: 90px;
    background: #fff;
    border-radius: 50%;
    z-index: 1;
    opacity: 0;
    -webkit-animation: warn 2s ease-out;
    -moz-animation: warn 2s ease-out;
    animation: warn 2s ease-out;
    animation-delay: 0.2s;
    -webkit-animation-iteration-count: infinite;
    -moz-animation-iteration-count: infinite;
    animation-iteration-count: infinite;
    }
    .pulse-mid {
    position: absolute;
    left: 4px;
    top: 4px;
    width: 82px;
    height: 82px;
    background: #ff5e39;
    border-radius: 50%;
    z-index: 1;
    opacity: 0;
    -webkit-animation: warn 1.8s ease-out;
    -moz-animation: warn 1.8s ease-out;
    animation: warn 1.8s ease-out;
    -webkit-animation-iteration-count: infinite;
    -moz-animation-iteration-count: infinite;
    animation-iteration-count: infinite;
    }
    .pulse-min {
    position: absolute;
    left: 7px;
    top: 7px;
    width: 76px;
    height: 76px;
    background: #fff;
    border-radius: 50%;
    z-index: 1;
    opacity: 0;
    -webkit-animation: warn 2s ease-out;
    -moz-animation: warn 2s ease-out;
    animation: warn 2s ease-out;

    CSS3达成的全荧屏覆盖层效果

    自家是在前端网看见的职能,点击这里步向,本身看完源码后兑现了一回,以下介绍具体步骤:

    剖析抖动

    图像由终端(显示屏)展现,而终端则是二个个光点(物理像素)组成的矩阵,换句话说图片也一组光点矩阵。为了便于描述,小编假如终端上的八个光点代表css中的1px。

    以下是一张 9px * 3px 的sprite:

    新葡亰496net 10

    每帧的尺寸为 3px * 3px,逐帧的取位进度如下:
    新葡亰496net 11

    把 sprite 的 background-size 的上升的幅度取百分之五十,那么极端会怎么处理?
    9 / 2 = 4.5
    终极的光点都以以自然数的样式出现的,这里需求做取整管理。取整日常是二种艺术:round/ceil/floor。假设是 round ,那么 background-size: 5px,sprite 会是以下两种的二个:

    情况一 情况二 情况三

    理论上,5 / 3 = 1.666...。但实际光点取整后,八个帧的增加率都不容许约等于 1.666...,而是有一个帧的宽窄降级为 1px(亏),此外多少个增幅晋级为 2px(盈),作者把那些景况称为「盈利和赔本互补」。

    再看一下盈利和亏折互补后,逐帧的取位进度:

    情况一 情况二 情况三

    能够观看由于盈利和亏折互补导致了三个帧的大幅度不等同,亏的那一帧在动画中的表示就是抖动

    作者总结抖动的缘故是:sprite在尺寸缩放后,帧与帧之间的盈利和亏空互补现象形成动画抖动

    附注:1px 由多少个光点表示是由以极端的 dpr 决定

    有关笔者:陈被单

    新葡亰496net 12

    热爱前端,接待沟通 个人主页 · 小编的小说 · 19 ·   

    新葡亰496net 13

    -webkit-animation-iteration-count: infinite;
    -moz-animation-iteration-count: infinite;
    animation-iteration-count: infinite;
    }
    .dot {
    position: absolute;
    left: 20px;
    top: 20px;
    width: 50px;
    height: 50px;
    line-height: 50px;
    color: #ff5e39;
    border-radius: 50%;
    background: #fff;
    z-index: 999;
    text-align: center;
    }

    新葡亰496net 14

    观察效果,能够将其分成多个圆和里面包车型地铁logo,所以轻松分为三部分

    减轻方案

    「盈亏互补」也能够说是「盈利和耗损不均等」,要是尺寸在缩放后「盈利和耗损一致」那么抖动现象能够减轻。

    </style>

    在线演示1在线演示2在线演示3在线演示4在线演示5本地下载

    <div > <div > </div> <div > </div> <div > </div></div>
    

    消除构想一

    作者依照「盈利和亏折一致」设计了「化解构想一」:

    新葡亰496net 15

    依照上海体育地方,其实很轻便就联想到一个简单易行的方案:不用Coca Cola图(即一帧对应一张图片)
    本条方案确实是能够缓和抖难点,然而小编并不引入应用它,因为它有四个负面包车型大巴东西:

    • KB变大与央浼数扩张
    • 多余的 animation 代码

    以此方案比很粗略,这里就不赘述了。

    </head>

    贰个应用CSS3生成的超酷幻灯效果,具备丰富棒覆盖效果,全部布置也十一分的通畅大气,大家能够平素下载演示看作用,也许使用GBdebug来在线调试。非常切合用户首页或然产品,文章集的展示。

    考察外面包车型大巴拱形,确定是用clip属性来促成了,明显要用4次,所以中间能够再分为四个部分,再用before和after五个伪成分,注意利用clip必得是用相对定位成分,具体clip里面包车型客车值的话能够逐渐调了,如若您是三个游戏迷的话,不仿完结三个和玩耍里一样的,多少个月前,当自家的爱人圈被那款游戏刷屏的时候,作者也想娱乐的,然而当本人打开官方网址的时候

    化解构想二

    把逐帧取位与图像缩放拆分成多个独立的长河,便是笔者的「化解构想二」:
    新葡亰496net 16

    贯彻「构想二」,小编首先想到的是运用 transform: scale(),于是整理了三个兑现方案A:

    .steps_anim { position: absolute; width: 360px; height: 540px; background: url(//misc.aotu.io/leeenx/sprite/m.png) 0 0 no-repeat; background-size: 1800px 540px; top: 50%; left: 50%; transform-origin: left top; margin: -5.625rem 0 0 -5.625rem; transform: scale(.5); animation: step 1.2s steps(5) infinite; } @keyframes step { 100% { background-position: -1800px; } } /* 写断点 */ @media screen and (width: 320px) { .steps_anim { transform: scale(0.4266666667); } } @media screen and (width: 360px) { .steps_anim { transform: scale(0.48); } } @media screen and (width: 414px) { .steps_anim { transform: scale(0.552); } }

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    .steps_anim {
      position: absolute;
      width: 360px;
      height: 540px;
      background: url(//misc.aotu.io/leeenx/sprite/m.png) 0 0 no-repeat;
      background-size: 1800px 540px;
      top: 50%;
      left: 50%;
      transform-origin: left top;
      margin: -5.625rem 0 0 -5.625rem;
      transform: scale(.5);
      animation: step 1.2s steps(5) infinite;
    }
    @keyframes step {
      100% {
        background-position: -1800px;
      }
    }
    /* 写断点 */
    @media screen and (width: 320px) {
    .steps_anim {
    transform: scale(0.4266666667);
    }
    }
    @media screen and (width: 360px) {
    .steps_anim {
    transform: scale(0.48);
    }
    }
    @media screen and (width: 414px) {
    .steps_anim {
    transform: scale(0.552);
    }
    }

    本条完结方案A存在明显的弱项:scale 的值需求写过多断点代码。于是作者结全一段 js 代码来改进那么些达成方案B:

    css:

    .steps_anim { position: absolute; width: 360px; height: 540px; background: url("//misc.aotu.io/leeenx/sprite/m.png") 0 0 no-repeat; background-size: 1800 540px; top: 50%; left: 50%; transform-origin: left top; margin: -5.625rem 0 0 -5.625rem; animation: step 1.2s steps(5) infinite; } @keyframes step { 100% { background-position: -1800px; } }

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    .steps_anim {
      position: absolute;
      width: 360px;
      height: 540px;
      background: url("//misc.aotu.io/leeenx/sprite/m.png") 0 0 no-repeat;
      background-size: 1800 540px;
      top: 50%;
      left: 50%;
      transform-origin: left top;
      margin: -5.625rem 0 0 -5.625rem;
      animation: step 1.2s steps(5) infinite;
    }
    @keyframes step {
      100% {
        background-position: -1800px;
      }
    }

    javascript:

    // 以下代码放到<head></head>中// <![CDATA[ document.write(" .steps_anim {scale(.5); } "); function doResize() { scaleStyleSheet.innerHTML = ".steps_anim {-webkit-transform: scale(" (document.documentElement.clientWidth / 750) ")}"; } window.onresize = doResize; doResize(); // ]]>

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    // 以下代码放到<head></head>中// <![CDATA[
    document.write("
     
    .steps_anim {scale(.5); }
     
     
    ");
    function doResize() {
      scaleStyleSheet.innerHTML = ".steps_anim {-webkit-transform: scale(" (document.documentElement.clientWidth / 750) ")}";
    }
    window.onresize = doResize;
    doResize();
    // ]]>

    因而核对后的方案 CSS 的断点没了,认为是情有可原了,不过小编以为那几个方案不是个纯粹的创设方案。

    大家理解<img> 是能够根据钦命的尺码自适应缩放尺寸的,假设逐帧动画也能与 <img> 自适应缩放,那就能够从纯营造角度完结「构想二」。

    SVG刚好能够化解难点!!!SVG 的表现与 <img>``类似同一时间能够做动画。以下是小编的落到实处方案C。

    html:

    JavaScript

    <svg viewBox="0, 0, 360, 540" class="steps_anim"> <image xlink:href="//misc.aotu.io/leeenx/sprite/m.png" width="1800" height="540" /> </svg>

    1
    2
    3
    <svg viewBox="0, 0, 360, 540" class="steps_anim">
      <image xlink:href="//misc.aotu.io/leeenx/sprite/m.png" width="1800" height="540" />
    </svg>

    css:

    JavaScript

    .steps_anim { position: absolute; width: 9rem; height: 13.5rem; top: 50%; left: 50%; margin: -5.625rem 0 0 -5.625rem; image { animation: step 1.2s steps(5) infinite; } } @keyframes step { 100% { transform: translate3d(-1800px, 0, 0); } }

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    .steps_anim {
      position: absolute;
      width: 9rem;
      height: 13.5rem;
      top: 50%;
      left: 50%;
      margin: -5.625rem 0 0 -5.625rem;
      image {
       animation: step 1.2s steps(5) infinite;
      }
    }
    @keyframes step {
      100% {
        transform: translate3d(-1800px, 0, 0);
      }
    }

    <body>
    <div class="container">

    CSS3兑现的歪曲文字效果

    新葡亰496net 17QQ截图20160816205229.png新葡亰496net 18

    方案C的改良

    实现方案C很好地消除了方案A和方案B的症结,但是方案C也会有它的标题:不便利自动化学工业具去管理图片

    自动化工具日常是怎么管理图片的?
    自动化学工业具平日是扫描 CSS 文件寻觅富有的 url(...) 语句,然后再管理这么些言辞指向的图样文件。

    如果 可以改用 CSS 的 `background-image` 就可以解决这个问题,不过 `SVG` 不支持 CSS 的 `background-image`。但是,`SVG`有一个扩展标签:`foreignObject`,它允许向 插入 html 代码。在运用它前,先看一下它的合作处境:

    新葡亰496net 19

    iOS 与 Android 4.3 一片深紫红宽容意况终于不错,小编实机测量试验Tencent X5 内核的浏览器宽容依然精粹。以下是革新后的方案。

    html:

    JavaScript

    <svg viewBox="0, 0, 360, 540" class="steps_anim"> <foreignObject class="html" width="360" height="540"> <div class="img"></div> </foreignObject> </svg>

    1
    2
    3
    4
    5
    <svg viewBox="0, 0, 360, 540" class="steps_anim">
      <foreignObject class="html" width="360" height="540">
        <div class="img"></div>
      </foreignObject>
    </svg>

    css:

    JavaScript

    .steps_anim { position: absolute; width: 9rem; height: 13.5rem; top: 50%; left: 50%; margin: -5.625rem 0 0 -5.625rem; } .html { width: 360px; height: 540px; } .img { width: 1800px; height: 540px; background: url(//misc.aotu.io/leeenx/sprite/m.png) 0 0 no-repeat; background-size: 1800px 540px; animation: step 1.2s steps(5) infinite; } @keyframes step { 100% { background-position: -1800px 0; } }

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    .steps_anim {
      position: absolute;
      width: 9rem;
      height: 13.5rem;
      top: 50%;
      left: 50%;
      margin: -5.625rem 0 0 -5.625rem;
    }
    .html {
    width: 360px;
    height: 540px;
    }
    .img {
    width: 1800px;
    height: 540px;
    background: url(//misc.aotu.io/leeenx/sprite/m.png) 0 0 no-repeat;
    background-size: 1800px 540px;
    animation: step 1.2s steps(5) infinite;
    }
    @keyframes step {
      100% {
        background-position: -1800px 0;
      }
    }

    更正后的方案DEMO:

    <div class="part">
    <div class="pulse-max"></div>
    <div class="pulse-mid"></div>
    <div class="pulse-min"></div>
    <div class="dot">额头</div>
    </div>
    </div>
    </body>
    </html>

    新葡亰496net 20

    小编竟无话可说,就算小编很协助正版,可是终归没钱。把外圆的有关样式丢进来,就能够达成效果与利益了,那几个第一也就在clip了

    总结

    多谢阅读完本小说的读者。本文是我的个人观点,希望能援救到有连带主题素材的爱侣,假如本文有不妥之处请多多支持。


    在线演示1本地下载

    <div > <div > <div ></div> <div ></div> </div> <div > </div> <div > </div></div>
    
    * { margin: 0; padding: 0;}html { height: 100%; background: #282828;}.overwatch-container { width: 232px; margin: 50px auto; position: relative;}.out-ring1 { height: 220px; width: 220px; position: absolute; top: 6px; left: 6px;}.out-ring1::before, .out-ring1::after { content: ""; height: 220px; width: 220px; border-radius: 50%; position: absolute; top: -6px; left: -6px; border: 6px solid rgba(161, 164, 176, 0.5);}.out-ring1::before { clip: rect(60px, 232px, 172px, 100px); transform: rotate;}.out-ring1::after { clip: rect(80px, 232px, 152px, 100px); transform: rotate;}.out-ring2 { position: absolute; top: 6px; left: 6px;}.out-ring2::before, .out-ring2::after { content: ""; height: 220px; width: 220px; border-radius: 50%; position: absolute; top: -6px; left: -6px; border: 6px solid rgba(161, 164, 176, 0.5);}.out-ring2::before { clip: rect(105px, 232px, 127px, 100px);}.out-ring2::after { clip: rect(112px, 232px, 120px, 100px);}
    

    参谋资料:



    1 赞 4 收藏 评论

    新葡亰496net 21

    不行非常的一款成效,鼠标离开就能够变得近乎有个别近视度同样的模糊,但把鼠标移动回来,却又清晰起来。那样效果假使用在乞巧节告白上,大概会更有效用呢。

    因为里面包车型客车圆的侧重于动画效果,故先写logo,观看logo,能够明白,这里见到这里料定要用到transform:rotate那个本性,logo中必然是三个大圆,别的一些能够透过方块实现,而最中间的有的能够用三角来落到实处,css画三角形使用border就足以,具体的rotate须求实际调

    用CSS3落到实处的按键效果

    <div > <div > <div ></div> <div ></div> </div> <div > </div> <div > <div ></div> <div ></div> </div></div>
    
    * { margin: 0; padding: 0;}html { height: 100%; background: #282828;}.overwatch-container { width: 232px; margin: 50px auto; position: relative;}.out-ring1 { height: 220px; width: 220px; position: absolute; top: 6px; left: 6px;}.out-ring1::before, .out-ring1::after { content: ""; height: 220px; width: 220px; border-radius: 50%; position: absolute; top: -6px; left: -6px; border: 6px solid rgba(161, 164, 176, 0.5);}.out-ring1::before { clip: rect(60px, 232px, 172px, 100px); transform: rotate;}.out-ring1::after { clip: rect(80px, 232px, 152px, 100px); transform: rotate;}.out-ring2 { position: absolute; top: 6px; left: 6px;}.out-ring2::before, .out-ring2::after { content: ""; height: 220px; width: 220px; border-radius: 50%; position: absolute; top: -6px; left: -6px; border: 6px solid rgba(161, 164, 176, 0.5);}.out-ring2::before { clip: rect(105px, 232px, 127px, 100px);}.out-ring2::after { clip: rect(112px, 232px, 120px, 100px);}.inner-img { width: 120px; height: 120px; border: 20px solid #B6B8C0; background: transparent; border-radius: 50%; position: absolute; left: 0; top: 0; margin: 36px;}.inner-img::before { content: ""; height: 20px; width: 66px; position: absolute; background: #B6B8C0; bottom: 0; left: 0; transform: rotate; transform-origin: left;}.inner-img::after { content: ""; height: 20px; width: 66px; position: absolute; background: #B6B8C0; bottom: 0; right: 0; transform: rotate; transform-origin: right;}.inner-img-shelter::before, .inner-img-shelter::after { content: ""; height: 4px; width: 21px; background: #282828; position: absolute; top: 15px;}.inner-img-shelter::before { left: -4px; transform: rotate; transform-origin: bottom right;}.inner-img-shelter::after { right: -4px; transform: rotate; transform-origin: bottom left;}.inner-img-triangle::before { content: ""; width: 0px; height: 0px; border-width: 0px 0px 50px 20px; border-left-color: transparent; border-bottom-color: #B6B8C0; border-style: solid; position: absolute; top: 20px; left: 34px;}.inner-img-triangle::after { content: ""; width: 0px; height: 0px; border-width: 0px 20px 50px 00px; border-right-color: transparent; border-bottom-color: #B6B8C0; border-style: solid; position: absolute; top: 20px; right: 34px;}
    

    新葡亰496net 22

    里圆的职能侧重于动画了,里面包车型客车职能都是经过不断调解达成的,笔者也是看的源代码,里面包车型地铁作用终归如故主题的圆形loading加载动画,日常圆形的进度条大家得以使用方面提到的clip达成

    在线演示1本地下载

    新葡亰496net 2323333

    用CSS3 落成的两种开关的机能。当鼠标滑过开关,就能够看来分化的作用啊!

    <!DOCTYPE html><html><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><title> loading</title><meta name="description" content=""><meta name="keywords" content=""><link href="" rel="stylesheet"><style> *{ margin:0; padding:0; } body{ width:220px; margin:20px auto; } .loading-container{ position:relative; } .loading{ width:200px; height:200px; border-radius: 50%; border:10px solid yellow; animation: loading 2s linear infinite; position:absolute; } .loading2{ width:200px; height:200px; border-radius:50%; border:10px solid yellow; position:absolute; transform: rotate; clip:rect(0px,0px,0px,0px); animation:loading2 2s linear infinite; } @keyframes loading{ 0%{ clip:rect(0px, 220px,0px,110px); } 50%{ clip:rect(0px,220px,220px,110px); } 100%{ clip:rect(0px,220px,220px,110px); } } @keyframes loading2{ 0%{ clip:rect(0px, 220px,0px,110px); } 50%{ clip:rect(0px, 220px,0px,110px); } 100%{ clip:rect(0px, 220px,220px,110px); } }</style></head><body> <div > <div ></div> <div ></div> </div></body></html>
    

    超棒CSS3动画泡沫开关,不影响旧版本浏览器选用

    就算因此js增加一些数字就愈加形象了

    新葡亰496net 24

    新葡亰496net 252334.gif

    在线演示1本地下载

    <!DOCTYPE html><html><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><title> loading</title><meta name="description" content=""><meta name="keywords" content=""><link href="" rel="stylesheet"><style>*{margin:0;padding:0;}body{width:220px;margin:20px auto;}.loading-container{position:relative;}.loading{width:200px;height:200px;border-radius: 50%;border:10px solid yellow;animation: loading 2s linear infinite;position:absolute;}.loading2{width:200px;height:200px;border-radius:50%;border:10px solid yellow;position:absolute;transform: rotate;clip:rect(0px,0px,0px,0px);animation:loading2 2s linear infinite;}@keyframes loading{0%{clip:rect(0px, 220px,0px,110px);}50%{clip:rect(0px,220px,220px,110px);}100%{clip:rect(0px,220px,220px,110px);}}@keyframes loading2{0%{clip:rect(0px, 220px,0px,110px);}50%{clip:rect(0px, 220px,0px,110px);}100%{clip:rect(0px, 220px,220px,110px);}}</style></head><body><div ><div ></div><div ></div></div><script>var number=document.getElementById;function changeNumber(){var text=number.innerText;var newText=Number(text.replace;if(newText<100){newText ;}else{clearTimeout;}number.innerText=newText "%";var timer=setTimeout(changeNumber,20);}changeNumber();</script></body></html>

    老大讨人喜欢的泡沫开关!适用于两种风格的网址。

    使用clip的一个特点是过程中会出现棱角,这个可能不是我们想要的,我们可以使用border来代替,从而消除棱角
    

    CSS3落到实处的超棒3D Grid效果

    <!DOCTYPE html><html><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><title> loading2</title><meta name="description" content=""><meta name="keywords" content=""><link href="" rel="stylesheet"><style>*{margin:0;padding:0;}body{width:220px;margin:20px auto;}.loading-container{position:relative;}.loading{width:110px;height:220px;position:absolute;overflow: hidden;}.loading-content{width:200px;height:200px;border:10px solid yellow;border-radius: 50%;border-bottom-color:transparent;border-right-color:transparent;transform:rotate;animation: loading 2s infinite linear;}.loading2{width:110px;height:220px;position:absolute;overflow: hidden;right:0;top:0;transform:rotate;}.loading2-content{width:200px;height:200px;border:10px solid yellow;border-radius: 50%;border-bottom-color:transparent;border-right-color:transparent;transform:rotate;animation: loading2 2s infinite linear;}.number{width:220px;height:40px;position:absolute;top:90px;text-align: center;font-size: 30px;font-weight:bold;}@keyframes loading{0%{transform: rotate;}50%{transform: rotate;}100%{transform: rotate;}}@keyframes loading2{0%{transform: rotate;}50%{transform: rotate;}100%{transform: rotate;}}</style></head><body><div ><div ><div ></div></div><div ><div ></div></div><div >0%</div></div><script>var number=document.getElementById;function changeNumber(){var text=number.innerText;var newText=Number(text.replace;if(newText<100){newText ;}else{clearTimeout;}number.innerText=newText "%";var timer=setTimeout(changeNumber,20);}changeNumber();</script></body></html>

    新葡亰496net 26

    而守望先锋的效果也正是这个的延伸的微调,具体可以看源码####四、添加动画效果####这里的动画效果没有什么技巧,只是不断的rotate微调而已,具体情况可以参照源码
    

    在线演示1在线演示2本地下载

    <div ><div ><div ></div><div ></div></div><div ><div ></div><div ><div ><div ></div></div></div><div ><div ><div ><div ></div></div></div><div ><div ><div ></div></div></div></div></div><div ><div ></div><div ></div></div></div>

    那么些棒的一款3D特效,作者自个儿特别欣赏3D效果,因为它能够让您真个页面看起来越发立体尤其丰硕!纵然你也和本身同样,急速来珍藏吧!

    • {margin: 0;padding: 0;}html {height: 100%;background: #282828;}.overwatch-container {width: 232px;margin: 50px auto;position: relative;}.out-ring1 {height: 220px;width: 220px;position: absolute;top: 6px;left: 6px;}.out-ring1::before, .out-ring1::after {content: "";height: 220px;width: 220px;border-radius: 50%;position: absolute;top: -6px;left: -6px;border: 6px solid rgba(161, 164, 176, 0.5);}.out-ring1::before {clip: rect(60px, 232px, 172px, 100px);transform: rotate;animation: out-ring1-before 3s cubic-bezier(0.34, 0.07, 0.68, 0.93) infinite}.out-ring1::after {clip: rect(80px, 232px, 152px, 100px);transform: rotate;animation: out-ring1-after 3s linear infinite}@keyframes out-ring1-before {from {transform: rotate;}to {transform: rotate;}}@keyframes out-ring1-after {from {transform: rotate;}to {transform: rotate;}}.out-ring2 {position: absolute;top: 6px;left: 6px;}.out-ring2::before, .out-ring2::after {content: "";height: 220px;width: 220px;border-radius: 50%;position: absolute;top: -6px;left: -6px;border: 6px solid rgba(161, 164, 176, 0.5);}.out-ring2::before {clip: rect(105px, 232px, 127px, 100px);animation: out-ring2-before 3s cubic-bezier(0.34, 0.07, 0.68, 0.93) infinite;}.out-ring2::after {clip: rect(112px, 232px, 120px, 100px);animation: out-ring2-before 3s linear infinite reverse;}@keyframes out-ring2-before {from {transform: rotate;}to {transform: rotate;}}@keyframes out-ring2-after {from {transform: rotate;}to {transform: rotate;}}.inner-img {width: 120px;height: 120px;border: 20px solid #B6B8C0;background: transparent;border-radius: 50%;position: absolute;left: 0;top: 0;margin: 36px;}.inner-img::before {content: "";height: 20px;width: 66px;position: absolute;background: #B6B8C0;bottom: 0;left: 0;transform: rotate;transform-origin: left;}.inner-img::after {content: "";height: 20px;width: 66px;position: absolute;background: #B6B8C0;bottom: 0;right: 0;transform: rotate;transform-origin: right;}.inner-img-shelter::before, .inner-img-shelter::after {content: "";height: 4px;width: 21px;background: #282828;position: absolute;top: 15px;}.inner-img-shelter::before {left: -4px;transform: rotate;transform-origin: bottom right;}.inner-img-shelter::after {right: -4px;transform: rotate;transform-origin: bottom left;}.inner-img-triangle::before {content: "";width: 0px;height: 0px;border-width: 0px 0px 50px 20px;border-left-color: transparent;border-bottom-color: #B6B8C0;border-style: solid;position: absolute;top: 20px;left: 34px;}.inner-img-triangle::after {content: "";width: 0px;height: 0px;border-width: 0px 20px 50px 00px;border-right-color: transparent;border-bottom-color: #B6B8C0;border-style: solid;position: absolute;top: 20px;right: 34px;}.inner-ring-container {width: 200px;height: 200px;position: absolute;top: 16px;left: 16px;background: transform;}.inner-ring1 {width: 180px;height: 180px;border: 10px solid #F9D64A;border-radius: 50%;position: absolute;clip: rect(90px, 200px, 110px, 110px);animation: inner-ring1 3s infinite linear;z-index: 2;}@keyframes inner-ring1 {from {transform: rotate;}to {transform: rotate;}}.inner-ring3 {width: 200px;height: 200px;background: transparent;position: absolute;top: 0;left: 0;animation: inner-ring3 infinite 2s linear;}.inner-ring3-container1 {width: 100px;height: 200px;overflow: hidden;position: absolute;top: 0;left: 0;}.inner-ring3-container1-content {width: 200px;height: 200px;position: absolute;animation: inner-ring3-container1-content 2s cubic-bezier(0, 0.5, 0.5, 1) infinite;}.inner-ring3-content1 {height: 180px;width: 180px;border-radius: 50%;border: 10px solid #4D4C2D;border-bottom-color: transparent;border-right-color: transparent;transform: rotate;animation: inner-ring3-content1 2s linear infinite;}@keyframes inner-ring3 {from {transform: rotate;}to {transform: rotate;}}@keyframes inner-ring3-content1 {from {transform: rotate;}35.5% {transform: rotate;}50% {transform: rotate;}to {transform: rotate;}}@keyframes inner-ring3-container1-content {0% {transform: rotate;}64.5% {transform: rotate;}100% {transform: rotate;}}.inner-ring3-container2 {width: 100px;height: 200px;overflow: hidden;position: absolute;top: 0;right: 0;}.inner-ring3-container2-content {width: 200px;height: 200px;position: absolute;top: 0;left: -100px;animation: inner-ring3-container2-content linear 2s infinite;}.inner-ring3-content2 {height: 180px;width: 180px;border-radius: 50%;border: 10px solid #4D4C2D;border-bottom-color: transparent;border-left-color: transparent;transform: rotate;animation: inner-ring3-content2 2s cubic-bezier(0.5, 0, 1, 0.5) infinite;}@keyframes inner-ring3-content2 {from {transform: rotate;}35.5% {transform: rotate;}to {transform: rotate;}}@keyframes inner-ring3-container2-content {0% {transform: rotate;}50% {transform: rotate;}64.5% {transform: rotate;}100% {transform: rotate;}}.inner-ring2 {width: 200px;height: 200px;z-index: 2;position: absolute;animation: inner-ring2 infinite 2s linear;}.inner-ring2-container {width: 100px;height: 200px;overflow: hidden;position: absolute;top: 0;left: 0;}.inner-ring2-content {height: 180px;width: 180px;border-radius: 50%;border: 10px solid #F9D64A;border-bottom-color: transparent;border-right-color: transparent;z-index: 2;animation: inner-ring2-content infinite linear 2s;}@keyframes inner-ring2 {0% {transform: rotate;}50% {transform: rotate;}100% {transform: rotate;}}@keyframes inner-ring2-content {0% {transform: rotate;}50% {transform: rotate;}100% {transform: rotate;}}

    CSS完结的变戏法小球

    新葡亰496net 27

    在线演示1

    #container {

    width: 200px;

    height: 50px;

    position: absolute;

    top: calc(50% 50px);

    left: calc(50% 50px);

    opacity: 0;

    animation: fadeIn 1s 1;

    animation-fill-mode: forwards;

    }

    .wrap {

    animation: translateX 1000ms infinite ease-in-out alternate;

    position: absolute;

    }

    .ball {

    width: 50px;

    height: 50px;

    box-shadow: -5px -5px 0 rgba(0, 0, 0, 0.15) inset;

    background-color: #397BF9;

    border-radius: 50%;

    animation: translateY 500ms infinite ease-in-out alternate;

    border: 2px solid black;

    }

    .wrap:after {

    content: '';

    width: 50px;

    height: 7.5px;

    background: #eee;

    position: absolute;

    bottom: 0;

    top: 70px;

    border-radius: 50%;

    animation: scale 500ms infinite ease-in-out alternate;

    }

    #wrap2, #ball2, #wrap2:after {

    animation-delay: -400ms;

    }

    #wrap3, #ball3, #wrap3:after {

    animation-delay: -800ms;

    }

    #wrap4, #ball4, #wrap4:after {

    animation-delay: -1200ms;

    }

    #wrap5, #ball5, #wrap5:after {

    animation-delay: -1600ms;

    }

    #ball2 {

    background-color: #F4B400;

    }

    #ball3 {

    background-color: #EEEEEE;

    }

    #ball4 {

    background-color: #00A656;

    }

    #ball5 {

    background-color: #E3746B;

    }

    @keyframes translateX {

    100% {

    transform: translateX(-150px);

    }

    }

    @keyframes translateY {

    100% {

    transform: translateY(-187.5px);

    }

    }

    @keyframes scale {

    100% {

    transform: scale(0.85);

    }

    }

    @keyframes fadeIn {

    新葡亰496net:推荐介绍8款CSS3落到实处的动态特效,逐帧动画抖动应用方案。100% {

    opacity: 1;

    }

    }

    复制代码

    运用CSS3 keyframe生成的有意思变戏法小球特效。相当风趣,假如在有个小人在旁边就更周全了不是啊?

    应用CSS3的step()生成的动画效果

    新葡亰496net 28

    在线演示1在线演示2在线演示3在线演示4本地下载

    在这里些DEMO中,将演示怎样利用CSS3的step()来处理动画效果。

    一举手一投足的小车:

    .contain-car {

    animation: drive 4s steps(4, end) infinite;

    }

    .contain-car-2 {

    animation: drive 4s steps(4, start) infinite;

    }

    @keyframes drive {

    to {

    transform: translateX(640px);

    }

    }

    复制代码

    原子钟效果:

    .second {

    animation: tick-tock 60s steps(60, end) infinite;

    }

    @keyframes tick-tock {

    to {

    transform: rotate(360deg);

    }

    }

    复制代码

    脚爪:

    .cover {

    animation: walk 7s steps(7, end) infinite;

    }

    @keyframes walk {

    to {

    transform: translateX(675px);

    }

    复制代码

    进度:

    .circle {

    animation: fill 5s steps(5, start) forwards;

    }

    @keyframes fill {

    to {

    opacity: 1;

    }

    }

    复制代码

    via:http://www.gbtags.com/gb/share/3557.htm

    本文由新葡亰496net发布于新葡亰官网,转载请注明出处:新葡亰496net:推荐介绍8款CSS3落到实处的动态特效

    关键词: