温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

使用CSS实现流星雨背景

发布时间:2021-06-03 17:58:43 阅读:186 作者:Leah 栏目:web开发
前端开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

使用CSS实现流星雨背景?相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。

vue页面使用

<template>
    <view class="space">
        <view class="planet">
            <view class="planet_shadow"></view>
            <view class="crater1"></view>
            <view class="crater2"></view>
            <view class="crater3"></view>
            <view class="crater4"></view>
        </view>
        <view class="stars">
            <view class="star"></view>
            <view class="star pink"></view>
            <view class="star blue"></view>
            <view class="star yellow"></view>
        </view>
    </view>
</template>

Style

<style lang="scss">
    .space {
        width100%;
        height100vh;
        background#121212;
    }

    .planet {
        width150px;
        height150px;
        border-radius50%;
        background#333;
        position: absolute;
        left50%;
        top50%;
        margin: -75px 0 0 -75px;
        overflow: hidden;
        z-index2;
    }

    .planet_shadow {
        position: absolute;
        border-radius50%;
        height100%;
        width100%;
        top: -40%;
        right: -10%;
        border35px solid rgba(000, .15);
    }

    .crater1,
    .crater2,
    .crater3,
    .crater4 {
        position: absolute;
        border-radius50%;
        backgroundrgba(000, .3);
        box-shadow: inset 3px 3px 0 rgba(000, .2);
    }

    .crater1 {
        width20px;
        height20px;
        left25%;
        top20%;
    }

    .crater2 {
        width10px;
        height10px;
        left50%;
        top60%;
    }

    .crater3 {
        width15px;
        height15px;
        left30%;
        top65%;
    }

    .crater4 {
        width15px;
        height15px;
        left60%;
        top35%;
    }

    .star {
        display: block;
        width5px;
        height5px;
        border-radius50%;
        background#FFF;
        top100px;
        left400px;
        position: relative;
        transform-origin100% 0;
        animation: star-ani 6s infinite ease-out;
        box-shadow0 0 5px 5px rgba(255255255, .3);
        opacity0;
        z-index2;
    }

    .star:after {
        content'';
        display: block;
        top0px;
        left4px;
        border0px solid #fff;
        border-width0px 90px 2px 90px;
        border-color: transparent transparent transparent rgba(255255255, .3);
        transformrotate(-45degtranslate3d(1px3px0);
        box-shadow0 0 1px 0 rgba(255255255, .1);
        transform-origin0% 100%;
        animation: shooting-ani 3s infinite ease-out;
    }

    .pink {
        top30px;
        left395px;
        background#ff5a99;
        animation-delay5s;
        -webkit-animation-delay5s;
        -moz-animation-delay5s;
    }

    .pink:after {
        border-color: transparent transparent transparent #ff5a99;
        animation-delay5s;
        -webkit-animation-delay5s;
        -moz-animation-delay5s;
    }

    .blue {
        top35px;
        left432px;
        background: cyan;
        animation-delay7s;
        -webkit-animation-delay7s;
        -moz-animation-delay7s;
    }

    .blue:after {
        border-color'transpareanimation-delay: 12s';
        -webkit-animation-delay7s;
        -moz-animation-delay7s;
        animation-delay7s;
    }

    .yellow {
        top50px;
        left600px;
        background#ffcd5c;
        animation-delay5.8s;
    }

    .yellow:after {
        border-color: transparent transparent transparent #ffcd5c;
        animation-delay5.8s;
    }

    @keyframes star-ani {
        0% {
            opacity0;
            transformscale(0rotate(0translate3d(000);
            -webkit-transformscale(0rotate(0translate3d(000);
            -moz-transformscale(0rotate(0translate3d(000);
        }

        50% {
            opacity1;
            transformscale(1rotate(0translate3d(-200px200px0);
            -webkit-transformscale(1rotate(0translate3d(-200px200px0);
            -moz-transformscale(1rotate(0translate3d(-200px200px0);
        }

        100% {
            opacity0;
            transformscale(1rotate(0translate3d(-300px300px0);
            -webkit-transformscale(1rotate(0translate3d(-300px300px0);
            -moz-transformscale(1rotate(0translate3d(-300px300px0);
        }
    }
</style>

看完上述内容,你们掌握使用CSS实现流星雨背景的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

原文链接:https://www.jb51.net/css/686006.html

css
AI

开发者交流群×