css3实现苹果loading动画

如图,苹果的loading图是这样的,今天写小程序的时候,想着加一个图片上传的loading动画,突然想到苹果的这个loading图标,于是想着怎么实现,去百度跟谷歌找了一下,发现没人发过?要不就是我搜索方式不对,于是想起以前做过一个类似的loading动画,由两个半圆组成。于是想着,这个有缺口的圆,想象成一个半圆加另外一个半圆旋转一定角度就可以了,想好就开工。

以下是实现代码:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        @keyframes roundAni {
            0% {
                transform: rotate(0deg);
            }
            100% {
                transform: rotate(360deg);
            }
        }

        .upload-content {
            position: relative;
            width: 100px;
            height: 100px;
            background-position: 50% 50%;
            background-size: cover;
            border: 1px solid red;
            margin: 20px 18px 0;
            background-color: red;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .round-loading-wrap {
            position: relative;
            width: 50px;
            height: 50px;
            animation: roundAni 1s linear infinite;
        }

        .round-loading {
            position: absolute;
            z-index: 2;
            border-radius: 100%;
            width: 50px;
            height: 50px;
            background-color: transparent;
            border: 2px solid red;
            border-bottom-color: transparent;
            border-left-color: transparent;
            box-sizing: border-box;
        }

        .round-loading-1 {
            transform: rotate(140deg);
        }
    </style>
</head>

<body>
    <div class="round-loading-wrap">
        <div class="round-loading"></div>
        <div class="round-loading round-loading-1"></div>
    </div>
</body>

</html>

动画的兼容性请自行解决,我用了webpack,会自动加前缀的。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值