zoukankan      html  css  js  c++  java
  • 10.纯 CSS 创作一个同心圆弧旋转 loader 特效

    原文地址:https://segmentfault.com/a/1190000014682999

    想到了扇形:正方形 -》border-radius: 50%; -》取四份中的任意一份。 

    不过如何取任意相关圆心角的扇形呢?

    HTML代码:

    <div class="circle"></div>

    CSS代码:

    html, body,.circle {
        margin: 0;
        padding: 0;
        height: 100%;
        display:flex;
        justify-content: center;
        align-items: center;
        
    }
    
    /* 优化代码 减少代码重复 */
    .circle,
    .circle::before,
    .circle::after {
        border-width: 0.4em;
        border-style: solid;
        border-radius: 50%;
        /* 使左右透明 ,只剩上下弧  如何任意该弧所占圆心角呢? */
        border-left-color: transparent;
        border-right-color: transparent;
        /* 动画名称 周期 节奏 循环次数 是否反向播放 */
        animation: animate 4s ease-in-out infinite alternate;
    }
    .circle{
        width:10em;
        height: 10em;
        border-top-color: red;
        border-bottom-color: blue;
        font-size: 20px;
        /* 定位会让其分离 */
        position: relative; 
        
    }
    .circle::before,
    .circle::after {
        content: '';
        position: absolute;
    }
    .circle::before {
        width: 70%;
        height: 70%;
        border-top-color: orange;
        border-bottom-color: cyan;
        animation-duration: 8s;
    }
    .circle::after {
        width: 40%;
        height: 40%;
        border-top-color: yellow;
        border-bottom-color: limegreen;
        animation-duration: 16s;
    }
    @keyframes animate {
        from {
            transform: rotate(0deg);
        }
        to {
            transform: rotate(1440deg);
        }
    }
  • 相关阅读:
    hdu 1124 OR toj 1065 简单数论
    this和判断的位置对赋值的要求
    快捷键操作
    常量池和堆的区别
    toString的用法
    使用泛型解决之前的问题
    不使用泛型会运行时会出现的问题
    集合图型
    代码块运行的优先级
    遍历集合的Iterator删除其中的元素
  • 原文地址:https://www.cnblogs.com/FlyingLiao/p/10136377.html
Copyright © 2011-2022 走看看