HTML5+CSS3小实例:炫彩爱心加载特效

HTML5+CSS3实现炫彩爱心加载特效,9根普通的线条,通过变换长度,即可打造一个动感炫彩的心形loading加载动画,变换过程伴随了模糊,更让这个loading动画更细腻、更富律动。

效果:

源码:





    
    

    炫彩爱心加载特效
    



    
body{
    margin: 0;
    /* 100%窗口高度 */
    height: 100vh;
    /* 弹性布局 水平、垂直居中 */
    display: flex;
    align-items: center;
    justify-content: center;
    /* 背景径向渐变 */
    background: radial-gradient(circle at center,mediumpurple, #000000);
}
.heart{
    width: 280px;
    height: 220px;
    font-size: 20px;
    display: flex;
    justify-content: space-between;
}
.heart span{
    /* 自定义属性值 */
    --c:lightblue;
    --h:50%;
    --t:25%;
    width: 20px;
    /* var()函数用于插入自定义的属性值,如果一个属性值在多处被使用,该方法就很有用 */
    background-color: var(--c);
    border-radius: 10px;
    position: relative;
    height: var(--h);
    top: var(--t);
    /* 执行动画 infinite是无限次播放 */
    animation: beating 1s infinite;
}
.heart span:nth-child(1),
.heart span:nth-child(9){
    --c:lightcoral;
    --h:60px;
    --t:44px;
}
.heart span:nth-child(2),
.heart span:nth-child(8){
    --c:lightskyblue;
    --h:120px;
    --t:12px;
}
.heart span:nth-child(3),
.heart span:nth-child(7){
    --c:lightgreen;
    --h:160px;
    --t:0;
}
.heart span:nth-child(4),
.heart span:nth-child(6){
    --c:gold;
    --h:180px;
    --t:16px;
}
.heart span:nth-child(5){
    --c:plum;
    --h:188px;
    --t:32px;
}

/* 接下来定义动画 */
@keyframes beating{
    0%,30%{
        height: var(--h);
        top: var(--t);
        background-color: var(--c);
        filter: blur(0);
    }
    60%,70%{
        height: 50%;
        top: 25%;
        background-color: plum;
        /* 模糊度 */
        filter: blur(5px);
    }
}

你可能感兴趣的:(HTML5+CSS3小实例:炫彩爱心加载特效)