zoukankan      html  css  js  c++  java
  • 71.纯 CSS 创作一个跳 8 字型舞的 loader

    原文地址:https://segmentfault.com/a/1190000015534639#articleHeader0

    感想:rotateX() 和rotateZ()一起使用好懵呀。

    HTML code:

    <div class="loader" title="8em,height:8em" >
        <span></span>
        <span></span>
        <span></span>
        <span></span>
        <span></span>
    </div>

    CSS code:

    html, body {
        margin: 0;
        padding: 0;
    }
    /* 设置所有元素的width、height包括其padding、border、content */
    *{
        box-sizing: border-box;
    }
    /* 设置body子元素水平垂直居中 */
    body {
        height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
        background-color: goldenrod;
    }
    /* 设置.loader容器样式 */
    .loader {
        position: relative;
        /* 在此修改font-size大小可以改变整个图形大小 */
        font-size: 30px;
        width: 8em;
        height: 8em;
        border: 1px solid black;
    } 
    /* 画出圆点span */
    .loader span{
        /* 绝对定位设置动画起始位置 */
        position: absolute;
        top: 4em;
        width: 1em;
        height: 1em;
        border-radius: 50%;
        background-color: #222;
        /* 设置旋转定点位置、动画、延时 */
        transform-origin: 4em top;
        animation: dance 2s linear infinite;
        animation-delay: calc((var(--n) - 5) * 0.2s);
    }
    @keyframes dance{
        to{
            /* rotateX绕x轴旋转  rotateZ绕z轴旋转 这里还是没弄明白 */
            transform: rotateX(360deg) rotateZ(360deg);
        }
    }
    .loader span:nth-child(1) { --n: 1; }
    .loader span:nth-child(2) { --n: 2; }
    .loader span:nth-child(3) { --n: 3; }
    .loader span:nth-child(4) { --n: 4; }
    .loader span:nth-child(5) { --n: 5; }
  • 相关阅读:
    缓存
    mybatis(ibatis)理解
    hibernate理解
    linux vi 命令
    Activity中ConfigChanges属性的用法
    sendStickyBroadcast和sendStickyOrderedBroadcast
    广播 BroadCastReceiver
    Android四大基本组件介绍与生命周期
    ubuntu14.04 开机自动运行应用程序
    Android中BindService方式使用的理解
  • 原文地址:https://www.cnblogs.com/FlyingLiao/p/10688191.html
Copyright © 2011-2022 走看看