用动画实现10种进度条样式

知识储备:

1.设计网页结构(html/5)
2.利用CSS3 的animation实现动画效果
3.给样式设置position属性,利用“父相子绝”实现定位
4.使用box-shadow实现小点点
效果如下:
在这里插入图片描述
结构如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>进度条</title>
    <link rel="stylesheet" href="CSS/pb.css">
</head>
<body>
    <div class="loading_1">
        <ul class="ul1">
            <li class="loading_1_1"></li>
            <li class="loading_1_2"></li>
            <li class="loading_1_3"></li>
            <li class="loading_1_4"></li>
            <li class="loading_1_5"></li>
        </ul>
        <p>loading...</p>
    </div>
    <div class="loading_2">
        <ul class="ul2">
            <li class="loading_2_1"></li>
            <li class="loading_2_2"></li>
            <li class="loading_2_3"></li>
            <li class="loading_2_4"></li>
            <li class="loading_2_5"></li>
        </ul>
        <p>loading...</p>
    </div>
    <div class="loading_3">
        <div class="circle1"></div>
        <div class="loading"><p>loading...</p></div>
        <div class="circle2"></div>
        <div class="circle3"></div>
    </div>
    <div class="loading_4">
        <div class="loading"><p>loading...</p></div>
        <div class="circle"></div>
    </div>
    <div class="loading_5">
        <div class="bg"></div>
        <div class="circle"></div>
        <span class="loadWord">loading</span><span class="loading"></span>
    </div>
    <div class="loading_6">
        <div class="circleOut"> <div class="circleIn"></div></div>
        <p>loading</p>
    </div>
    <div class="loading_7">
        <p>loading</p>
        <div class="loading">
            <span class="loading_7_1"></span>
            <span class="loading_7_2"></span>
            <span class="loading_7_3"></span>
            <span class="loading_7_4"></span>
            <span class="loading_7_5"></span>
            <span class="loading_7_6"></span>
        </div>
    </div>
    <div class="loading_8">
        <div class="bg"></div>
        <div class="loading"></div>
        <p>loading</p>
    </div>
    <div class="loading_9">
        <p class="loadingWord">loading</p>
        <span class="loading"></span>
    </div>
    <div class="loading_10">
        <div class="bg"></div>
        <div class="circle"></div>
    </div>
    </div>
</body>
</html>

样式设置如下
pb.css

*{
    margin:0;
    padding: 0;
}
body{
    background: gray;
}
div{
    display: block;
    float: left;
}
.loading_1{
    background: limegreen;
    width: 200px;
    height:200px;
    font-family: "黑体";
    color: white;
    font-size: 20px;
    text-align: center;
}
.ul1{
    padding:20px 5px;
    list-style: none;
}
.ul1 li{
    background: white;
    margin: 2px;
}
.loading_1_1{
    background: white;
    height:20px;
    /*transition: all 3s ease-in-out;*/
    animation: progressMove 2s ease-in-out both infinite alternate;
}
.loading_1_2{
    background: white;
    height:20px;
    /*transition: all 3s ease-in-out;*/
    animation: progressMove 1s ease-in-out 0.5s both infinite alternate;
}
.loading_1_3{
    background: white;
    /*width: 20px;*/
    height:20px;
    /*transition: all 3s ease-in-out;*/
    animation: progressMove 2s linear both infinite alternate;
}
.loading_1_4{
    background: white;
    /*width: 20px;*/
    height:20px;
    /*transition: all 3s ease-in-out;*/
    animation: progressMove 2s linear 0.5s both infinite alternate;
}
.loading_1_5{
    background: white;
    /*width: 20px;*/
    height:20px;
    /*transition: all 3s ease-in-out;*/
    animation: progressMove 3s ease-in 0.5s both infinite alternate;
}
.loading_1{
    background: limegreen;
    width: 200px;
    height:200px;
    font-family: "黑体";
    color: white;
    font-size: 20px;
    text-align: center;
}
/**/
.loading_2{
    background: skyblue;
    width: 200px;
    height:200px;
    font-family: "黑体";
    color: steelblue;
    font-size: 20px;
    text-align: center;
}
.ul2{
    padding:20px 5px;
    list-style: none;
}
.ul2 li{
    background: steelblue;
    margin: 2px;
}
.loading_2_1{
    /*background: white;*/
    height:20px;
    /*transition: all 3s ease-in-out;*/
    animation: progressMove 2s ease-in-out both infinite alternate;
}
.loading_2_2{
    /*background: white;*/
    height:20px;
    /*transition: all 3s ease-in-out;*/
    animation: progressMove 1s ease-in-out 0.5s both infinite alternate;
}
.loading_2_3{
    /*background: white;*/
    /*width: 20px;*/
    height:20px;
    /*transition: all 3s ease-in-out;*/
    animation: progressMove 2s linear both infinite alternate;
}
.loading_2_4{
    /*background: white;*/
    /*width: 20px;*/
    height:20px;
    /*transition: all 3s ease-in-out;*/
    animation: progressMove 2s linear 0.5s both infinite alternate;
}
.loading_2_5{
    /*background: white;*/
    /*width: 20px;*/
    height:20px;
    /*transition: all 3s ease-in-out;*/
    animation: progressMove 3s ease-in 0.5s both infinite alternate;
}

/**/
@keyframes progressMove {
    0%{
        width: 0;
    }
    100%{
        width:80%;
    }
}
/* 第三种   */
.loading_3{
    position: relative;
    background: red;
    width: 200px;
    height:200px;
    text-align: center;
    opacity: 70%;
    color: white;
}
.circle1{
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    top:10px;left: 90px;
    animation: move1 1s linear both infinite alternate;
}
@keyframes move1 {
    0%{
        top:10px;left: 90px;
    }
    100%{
        top:60px;left: 90px;
    }
}
.circle2{
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    left:10px;bottom: 10px;
    animation: move2 1s linear both infinite alternate;
}
@keyframes move2{
    0%{
    }
    100%{
        transform: translate(60px,-70px);
    }
}
.circle3{
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    right:10px;bottom: 10px;
    animation: move3 1s linear both infinite alternate;
}
@keyframes move3{
    0%{
    }
    100%{
        transform: translate(-60px,-70px);
    }
}
.loading_3 .loading{
    position: absolute;
    font-size: 20px;
    top:75px;left:60px;
}
/*four*/
.loading_4{
    position: relative;
    background: #fbc88f;
    width: 200px;
    height:200px;

    color: #FB7209;
}
.loading_4 .loading{
    position: absolute;
    font-size: 20px;
    top:60px;
    left: 60px;
}
.loading_4 .circle{
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #FB7209;
    left: 10px;top: 120px;
    animation: rotateMove4 1s linear both infinite;
}
@keyframes rotateMove4 {
    0%{
        opacity: 0;
    }
    50%{
        opacity: 100%;
        width: 20px;
        height: 20px;
        transform: translateX(90px);
    }
    100%{
        opacity: 0;
        width: 10px;
        height:10px;
        transform: translateX(180px);
    }
}
/*loading_5*/
.loading_5{
    position: relative;
    background: #944bc8;
    width: 200px;
    height:200px;
    color: white;
}
.loading_5 .bg {
    width: 25px;
    height: 25px;
    top:80px;left: 85px;
    border: 3px solid #ddd;
    opacity: 80%;
    border-radius: 50%;
    position: absolute;
    animation: move ease-in-out infinite ;
}
.loading_5 .circle{
    position:absolute;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border-right:1px solid rgb(255, 255, 255);
    animation: rotateMove5 1s linear both infinite;
    top:82px;left: 87px;
}
@keyframes rotateMove5 {
    from{
        transform: rotate(0deg);
    }
    to{
        transform: rotate(1080deg);
    }
}
.loading_5 .loadWord{
    position: absolute;
    top:125px;left:70px;
}
.loading_5 .loading{
    position: absolute;
    top:140px;left:130px;
    height: 2px;
    width: 2px;
    display: inline-block;
    /*box-shadow: 2px 0 0 white ,7px 0 0 white, 12px 0 0 white;*/
    animation: change 2.4s  infinite steps(1,start);
}
@keyframes change{
    25%{
        box-shadow: 2px 0 0 #fff;
    }
    50%{
        box-shadow: 2px 0 0 #fff ,7px 0 0 #fff;
    }
    75%{
        box-shadow: 2px 0 0 #fff ,7px 0 0 #fff, 12px 0 0 #fff;
    }
}
/*loading_6*/
.loading_6{
    position: relative;
    width: 200px;
    height: 200px;
    background: lightgray;
    color: white;
}
.circleOut{
    display: block;
    width:100px;
    height: 100px;
    position: absolute;
    top:50px;
    left: 50px;
    border-radius: 50%;
    border: 2px solid white;
    /*旋转*/
    animation:circleRoate 2s ease-in-out infinite;

}
.circleIn{
    position: absolute;
    width:10px;
    height: 10px;
    border-radius: 50%;
    background: white;
    top:8px;
    left:8px;
}
@keyframes circleRoate{
    from{transform: rotate(0deg) ;}
    to{transform: rotate(360deg);}
}
.loading_6 p{
    position: absolute;
    top:90px;
    left:72px;
}
/*loading7*/
.loading_7{
    position: relative;
    background: darkmagenta;
    color: white;
    width: 200px;
    height:200px;
}
.loading_7 p{
    position: absolute;
    left:70px;top:70px;
}
 .loaing_7 loading {
    border:1px solid black;
    position: absolute;
    list-style: none;
    margin-left: 10px;margin-right: 10px;
    top:100px;
}
.loading_7_1 {
    position: absolute;
    background: white;
    width: 10px;

    top: 120px;
    left: 40px;
    animation: colMove 1s linear infinite alternate;
}
.loading_7_2{
    position: absolute;
    background: white;
    width:10px;
    height: 50px;
    left:60px;top:120px;
    animation:colMove 1s 0.5s linear infinite alternate;
}
.loading_7_3{
    position: absolute;
    background: white;
    width:10px;
    height: 50px;
    left:80px;top:120px;
    animation:colMove 1s 1.5s linear infinite alternate;
}
.loading_7_4{
    position: absolute;
    background: white;
    width:10px;
    height: 50px;
    left:100px;top:120px;
    animation:colMove 1s 2s linear infinite alternate;
}
.loading_7_5{
    position: absolute;
    background: white;
    width:10px;
    height: 50px;
    left:120px;top:120px;
    animation:colMove 1s 2.5s linear infinite alternate;
}
.loading_7_6{
    position: absolute;
    background: white;
    width:10px;
    height: 50px;
    left:140px;top:120px;
    animation:colMove 1s 3s linear infinite alternate;
}
@keyframes colMove {
    0%{
        height: 0;
    }
    100%{
        height: 50px;
    }
}
/*loading 8*/
.loading_8{
    position: relative;
    background: rgba(0, 0, 0, 0.75);
    width:200px;
    height: 200px;
}
.loading bg{
    position: absolute;
    top:90px;
    left: 25px;
    background: black;
    width:150px;
    height:20px;
    border-radius: 10%;
    /*animation: loadingMove 2s 1s linear infinite;*/
}
.loading_8 .loading{
    position: absolute;
    top:73px;
    left: 25px;
    width:150px;
    height:20px;
    border-radius: 10%;
    animation: loadingMove 5s linear infinite;
}
@keyframes loadingMove {
    0%{
        width: 0;
        background: greenyellow;
    }
    100%{
        width: 150px;
        background: greenyellow;
    }
}
.loading_8 p{
    position: absolute;
    top:72px;
    left: 25px;
    text-align: center;
    width:150px;
    height: 20px;
}
/*loading9*/
.loading_9{
    position: relative;
    background: greenyellow;
    width: 200px;
    height:200px;
}
.loading_9 .loading{
    position: absolute;
    top:120px;left:40px;
    height:20px;
    width:20px;
    border-radius: 50%;
    /*box-shadow: 2px 0 0 white ,7px 0 0 white, 12px 0 0 white;*/
    animation: showMove 2s infinite steps(1,start),showMove2 2s linear infinite;
}
@keyframes showMove {
    12.5%{
        box-shadow: 20px 0 0 black;
    }
    25%{
        box-shadow:20px 0 0 black,50px 0 0 black;
    }
    37.5%{border-radius: 0;
        box-shadow:20px 0 0 black ,50px 0 0 black,80px 0 0 black;
    }
    50%{
        box-shadow: 20px 0 0 black;
    }
    62.5%{
        box-shadow:20px 0 0 black,50px 0 0 black;
    }
    75%{
        box-shadow: 20px 0 0 black ,50px 0 0 black,80px 0 0 black;
    }
}
@keyframes showMove2 {
    0%{
        opacity:0;
    }
    50%{
        opacity: 100%;
    }
    100%{
        opacity:0%;
    }
}
@keyframes changeMove2{
    25%{
        box-shadow: 20px 0 0 black;
    }
    50%{
        box-shadow:20px 0 0 black,50px 0 0 black;
    }
    75%{
        box-shadow: 20px 0 0 black ,50px 0 0 black,80px 0 0 black;
    }
}
@keyframes changeMove2 {
    0%{
        opacity: 0;
    }
    100%{
        opacity: 100%;
    }
}
.loading_9 .loadingWord{
    position: absolute;
    top:70px;left:70px;
}
/*loading_10*/
.loading_10{
    width: 200px;
    height: 200px;
    position: relative;
    background: #f6ff8c;
}
.loading_10 .circle{
    margin: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    position: absolute;
    border:5px solid transparent;
    top: 0;
    border-right:5px solid rgba(152, 152, 152, 0.87);
    border-left:5px solid rgba(152, 152, 152, 0.87);
    animation: move 1s ease-in-out infinite alternate;
}
@keyframes move {
    from{
        transform: rotate(0deg);
    }
    to{
        transform: rotate(360deg);
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值