前端入门(加载特效,css)

在这里插入图片描述在这里插入图片描述
哈哈效果你们就这么看看吧,实在不会截取 gif ,将就将就,或者复制粘贴代码去看看吧(最好还是去看看效果)

这个效果简单说就是有一个带有一半黑边框的圆用 ease-out (最后以慢速度结尾)进行旋转,还有一个半白边框的圆用 ease-in-out (以慢速度开头与结尾)进行旋转(用来覆盖黑边框),完成该效果,最终效果就是,黑边框先快速“摆脱”白边框(加载条变长),然后最后再变慢,最后在一个位置结尾(加载条变短)

这个效果是由 3 个部分完成
#loading_item 用一个比较慢的速度进行旋转,于是每次旋转的起始位置不同(当然也可以设置让它别转了,这样每次起始位置就相同)
#loading_item::before 充当半个黑边框的圆
#loading_item::after 充当半个白边框的圆
(注意哈,这个before和after不能交换位置,否则白边框到了黑边框下面,就什么作用都没了)

还有一些小细节:

  1. 比如这个白边框一定要比黑边框粗,并且一定要调节位置,把这个黑边框给覆盖好,不然效果很丑很丑
  2. 这个虽然是设置一半的边框颜色,但另一半的边框也要设置宽度,不然边框会变得一边宽一边细,那真的视觉灾难

( yysy , 还是蛮简单的,推荐试一下)

<!DOCTYPE html>
<html>
    <head>
        <style>
            *{
                padding: 0px;
                margin: 0px;
            }
            #loading_item{
                position: absolute;
                left: 50vw;
                top: 50vh;
                width: 200px;
                height: 200px;
                border-radius: 50%;
                transform: translate(-100px,-100px);
                background-color: white;
                animation-name: rotating_1;
                animation-duration: 10s;
                animation-iteration-count: infinite;
                animation-timing-function: linear;
            }
            #loading_item::after{
                content: "";
                position: absolute;
                left: -2px;
                top: -2px;
                width: 195px;
                height: 195px;
                border-radius: 50%;
                border-style: solid;
                border-width: 7px;
                border-left-color: white;
                border-bottom-color: white;
                border-right-color: transparent;
                border-top-color: transparent;
                background-color: transparent;
                animation-name: rotating_2;
                animation-duration: 5s;
                animation-iteration-count: infinite;
                animation-timing-function: ease-in-out;
            }
            #loading_item::before{
                content: "";
                position: absolute;
                width: 200px;
                height: 200px;
                border-radius: 50%;
                border-style: solid;
                border-width: 3px;
                border-left-color: black;
                border-bottom-color: black;
                border-right-color: transparent;
                border-top-color: transparent;
                background-color: transparent;
                animation-name: rotating_2;
                animation-duration: 5s;
                animation-iteration-count: infinite;
                animation-timing-function: ease-out;
            }
            @keyframes rotating_1 {
                to {transform: translate(-100px,-100px) rotate(360deg)}
            }
            @keyframes rotating_2 {
                to {transform: rotate(360deg)}
            }
        </style>
    </head>
    <body>
        <div id = 'loading_item'></div>
    </body>
</html>
  • 6
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值