028-86922220

建站动态

根据您的个性需求进行定制 先人一步 抢占小程序红利时代

CSS3怎么实现流星雨效果

小编给大家分享一下CSS3怎么实现流星雨效果,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

土默特左旗网站建设公司创新互联,土默特左旗网站设计制作,有大型网站制作公司丰富经验。已为土默特左旗超过千家提供企业网站建设服务。企业网站搭建\成都外贸网站建设公司要多少钱,请找那个售后服务好的土默特左旗做网站的公司定做!

说明:正文只讲述单个流星雨的实现方式,多个的效果只需要对单个的动画起始点、宽度稍加修改即可,具体示例见文末 github 地址。

难度系数

☆☆☆☆☆

效果图

CSS3怎么实现流星雨效果

思路

流星雨的实现分为三部分:

(1)用 border 属性实现直角三角形。三角形的实现可以参考 CSS绘制三角形

(2)给直角三角形添加圆形效果,弱化直角形状的棱角

(3)添加动画效果,让直角三角形动起来

HTML

解析:

CSS

.shooting-star {
    margin: 30px;
    display: block;
    width: 0;
    border-radius: 2px;
    border-top-width: 1px;
    border-top-style: solid;
    border-top-color: transparent;
    border-left-width: 230px;
    border-left-style: solid;
    border-left-color: white;
    border-right-width: 230px;
    border-right-style: solid;
    border-right-color: transparent;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    border-bottom-color: white;
}
.animation {
    animation: fly 3s infinite;
}
@keyframes fly {
    from {
        margin-left: 900px;
        border-left-width: 130px;
        border-right-width: 130px;
    }
    to {
        margin-left: -900px;
        border-left-width: 360px;
        border-right-width: 360px;
    }
}

解析:

知识点

Gitbub 源码:

https://github.com/nanzhangren/CSS_skills/blob/master/shooting_star/shooting_star.html

以上是“CSS3怎么实现流星雨效果”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注创新互联行业资讯频道!


网页标题:CSS3怎么实现流星雨效果
链接分享:http://www.tsicrk.com/article/gsigco.html

其他资讯

让你的专属顾问为你服务

2.6090s