温馨提示×

温馨提示×

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

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

如何使用css代码实现纸飞机效果

发布时间:2021-06-29 11:36:04 来源:亿速云 阅读:653 作者:小新 栏目:web开发

这篇文章主要介绍了如何使用css代码实现纸飞机效果,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。

实现效果图如下:

如何使用css代码实现纸飞机效果

实例代码如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>纸飞机</title>
    <style>
        .wrap {
            position: relative;
            display: inline-block;
            width: 300px;
            height: 120px;
            -webkit-animation: fly 6s;
            -moz-animation: fly 6s;
            -o-animation: fly 6s;
            animation: fly 6s;:
        }
        .triangle1 { /*黄色三角形*/
            position: absolute;
            top: 50px;
            left: 8px;
            height: 0;
            width: 0;
            border-left: 100px solid rgba(255, 255, 255, 0);
            border-right: 180px solid rgba(255, 255, 255, 0);
            border-bottom: 24px solid #f09c18;
            -webkit-transform: rotate(-10deg);
            -moz-transform: rotate(-10deg);
            -ms-transform: rotate(-10deg);
            -o-transform: rotate(-10deg);
            transform: rotate(-10deg);
        }
        .triangle1:after { /*红色边线*/
            position: absolute;
            left: -100px;
            content: '';
            display: block;
            width: 280px;
            height: 24px;
            border-bottom: 1px solid red;
        }
        .triangle2 { /*绿色三角形*/
            position: absolute;
            top: 39px;
            left: 66px;
            height:0;
            width: 0;
            border-left: 40px solid rgba(255, 255, 255, 0);
            border-right: 180px solid rgba(255, 255, 255, 0);
            border-top: 24px solid #07d362;
            -webkit-transform: rotate(5.2deg);
            -moz-transform: rotate(5.2deg);
            -ms-transform: rotate(5.2deg);
            -o-transform: rotate(5.2deg);
            transform: rotate(5.2deg);
        }
        .triangle2:after { /*黄色边线*/
            position: absolute;
            top: -24px;
            left: -40px;
            content: '';
            display: block;
            width: 220px;
            height: 24px;
            border-top: 1px solid yellow;
        }
        .triangle3 { /*黑色三角形*/
            position: absolute;
            top: 68px;
            left: 100px;
            height: 0;
            width: 0;
            border-left: 6px solid rgba(255, 255, 255, 0);
            border-right: 100px solid rgba(255, 255, 255, 0);
            border-bottom: 12px solid #2e302c;
            -webkit-transform: rotate(-16.8deg);
            -moz-transform: rotate(-16.8deg);
            -ms-transform: rotate(-16.8deg);
            -o-transform: rotate(-16.8deg);
            transform: rotate(-16.8deg);
        }
        @keyframes fly { /*定义动画*/
            0% {
                top: 0;
                left: 0;
            }
            5% {
                -webkit-transform: rotate(10deg);
                -moz-transform: rotate(10deg);
                -ms-transform: rotate(10deg);
                -o-transform: rotate(10deg);
                transform: rotate(10deg);
            }
            50% {
                top: 200px;
                left: 800px;
                -webkit-transform: rotate(10deg);
                -moz-transform: rotate(10deg);
                -ms-transform: rotate(10deg);
                -o-transform: rotate(10deg);
                transform: rotate(10deg);
            }
            55% {
                -webkit-transform: rotate(170deg) rotateX(180deg);
                -moz-transform: rotate(170deg) rotateX(180deg);
                -ms-transform: rotate(170deg) rotateX(180deg);
                -o-transform: rotate(170deg) rotateX(180deg);
                transform: rotate(170deg) rotateX(180deg);
            }
            100% {
                top: 400px;
                left: 0;
                -webkit-transform: rotate(170deg) rotateX(180deg);
                -moz-transform: rotate(170deg) rotateX(180deg);
                -ms-transform: rotate(170deg) rotateX(180deg);
                -o-transform: rotate(170deg) rotateX(180deg);
                transform: rotate(170deg) rotateX(180deg);
            }
        }
    </style>
</head>
<body>
    <div class="wrap">
        <div class="triangle1"></div>
        <div class="triangle2"></div>
        <div class="triangle3"></div>
    </div>
</body>
</html>

感谢你能够认真阅读完这篇文章,希望小编分享的“如何使用css代码实现纸飞机效果”这篇文章对大家有帮助,同时也希望大家多多支持亿速云,关注亿速云行业资讯频道,更多相关知识等着你来学习!

向AI问一下细节

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

css
AI