CSS动画实现星星闪烁效果

在这里插入图片描述
一闪一闪亮晶晶,用来做背景很棒哦~

html部分

<div class="container">
       <div class="star star1"></div>
       <div class="star star2"></div>
       <div class="star star3"></div>
   </div> 

CSS部分

body { overflow: hidden; }
.container {
    position   : relative;
    top        : 0;
    left       : 50%;
    transform: translateX(-50%);
    width      : 1920px;
    height     : 600px;
    background : url(images/bg1.jpg) repeat
}

.star {
    position : absolute;
    top      : 0;
    left     : 50%;
    transform: translateX(-50%);
    width    : 1920px;
    height   : 500px;
    animation: star 2.5s ease-in infinite;
}

.star1 {
    background: url(images/bg_star_1.png) no-repeat center center;

}

.star2 {
    background: url(images/bg_star_2.png) no-repeat center center; animation-delay: .8s;
}

.star3 {
    background: url(images/bg_star_3.png) no-repeat center center; animation-delay: 1.7s;
}

@keyframes star {
    10% {
        opacity: 0;
    }

    90% {
        opacity: 1;
    }
}

animation是个宝藏

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

immocha

人生得意须尽欢

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值