切图+动画实现图形转换

本文通过HTML和CSS技术详细介绍了如何创建图形转换效果,包括具体的代码示例,展示了从一种图形动态转变成另一种图形的过程。
摘要由CSDN通过智能技术生成

实现效果

动画

代码示例
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>图形转换</title>
    <style>
        body {
            background-color: rgb(7, 7, 122);
        }
        .box {
            position: relative;
            width: 500px;
            height: 500px;
            margin: auto;
            margin-top: 250px;
        }
        .one{
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
        }
        .b1,.b2,.b3 ,.b4,.b5{
            background-color: #104066;
        }
        .b1 {
           animation: a1 5s 2s ease-in-out infinite  forwards alternate;
            clip-path: polygon(109px 156px,184px 125px,111px 179px);
        }
        .b2 {
            animation: a2 5s 2s ease-in-out infinite forwards alternate;
            clip-path: polygon(71px 156px,144px 110px, 184px 125px);
        }
        .b3 {
            animation: a3 5s 2s ease-in-out infinite forwards alternate;
            clip-path: polygon(184px 125px,111px 179px,152px 166px);
        }
        .b4 {
            animation: a4 5s 2s ease-in-out infinite forwards alternate;
            clip-path: polygon(152px 166px,111px 179px,118px 199px);
        }
        .b5 {
            animation: a5 5s 2s ease-in-out infinite forwards alternate;
            clip-path: polygon(152px 166px,133px 214px,118px 199px);
        }
        .b6,.b7,.b8,.b9,.b10 ,.b11,.b12,.b13,.b14,.b15,.b16,.b17,.b21{
            background-color: #0d86a1;
        }
        .b6{
            animation: a6 5s 2s ease-in-out infinite forwards alternate;
           
            clip-path: polygon(184px 125px,144px 110px,185px 91px);
        }
        .b7 {
            animation: a7 5s 2s ease-in-out infinite forwards alternate;
            clip-path: polygon(184px 125px,185px 91px,240px 104px);
        }
        .b8 {
            animation: a8 5s 2s ease-in-out infinite forwards alternate;
            clip-path: polygon(185px 91px,240px 104px,210px 90px);
        }
        .b9 {
            animation: a9 5s 2s ease-in-out infinite forwards alternate;
            clip-path: polygon(240px 104px,210px 90px,241px 90px);
        }
        .b10 {
            animation: a10 5s 2s ease-in-out infinite forwards alternate;
            clip-path: polygon(210px 90px,241px 90px,275px 103px);
        }
        .b11 {
            animation: a11 5s 2s ease-in-out infinite forwards alternate;
            clip-path: polygon(241px 90px,275px 103px,308px 108px);
        }
        .b12 {
            animation: a12 5s 2s ease-in-out infinite forwards alternate;
            clip-path: polygon(185px 91px,132px 57px,145px 81px);
        }
        .b13 {
            animation: a13 5s 2s ease-in-out infinite forwards alternate;
            clip-path: polygon(185px 91px,145px 81px,147px 93px);
        }
        .b14 {
            animation: a14 5s 2s ease-in-out infinite forwards alternate;
            clip-path: polygon(144px 110px,185px 91px,147px 93px);
        }
        .b15 {
            animation: a15 5s 2s ease-in-out infinite forwards alternate;
            clip-path: polygon(133px 214px,161px 232px,136px 254px);
        }
        .b16 {
            animation: a16 5s 2s ease-in-out infinite forwards alternate;
            clip-path: polygon(161px 232px,136px 254px,149px 256px);
        }
        .b17 {
            animation: a17 5s 2s ease-in-out infinite forwards alternate;
            clip-path: polygon(136px 254px,149px 256px,149px 273px);
        }
        .b18,.b19,.b20,.b22,.b23,.b24,.b25,.b26,.b27 ,.b28,.b29,.b30,.b31,.b32,.b33,.b34,.b35,.b36{
            background-color: #9aafb2;
        }
        .b18 {
            animation: a18 5s 2s ease-in-out infinite forwards alternate;
            clip-path: polygon(275px 103px,308px 108px,287px 129px);
        }
        .b19 {
            animation: a19 5s 2s ease-in-out infinite forwards alternate;
            clip-path: polygon(275px 103px,287px 129px,254px 123px);
        }
        .b20 {
            animation: a20 5s 2s ease-in-out infinite forwards alternate;
            clip-path: polygon(275px 103px,254px 123px,240px 104px);
        }
        .b21 {
            animation: a21 5s 2s ease-in-out infinite forwards alternate;
            clip-path: polygon(240px 104px,275px 103px,241px 90px);
        }
        .b22 {
            animation: a22 5s 2s ease-in-out infinite forwards alternate;
            clip-path: polygon(254px 123px,240px 104px,184px 125px);
        }
        .b23 {
            animation: a23 5s 2s ease-in-out infinite forwards alternate;
            clip-path: polygon(254px 123px,184px 125px,253px 149px);
        }
        .b24 {
            animation: a24 5s 2s ease-in-out infinite forwards alternate;
            clip-path: polygon(254px 123px,253px 149px,276px 139px);
        }
        .b25 {
            animation: a25 5s 2s ease-in-out infinite forwards alternate;
            clip-path: polygon(184px 125px,253px 149px,210px 157px);
        }
        .b26 {
            animation: a26 5s 2s ease-in-out infinite forwards alternate;
            clip-path: polygon(253px 149px,210px 157px,238px 170px);
        }
        .b27 {
            animation: a27 5s 2s ease-in-out infinite forwards alternate;
            clip-path: polygon(253px 149px,238px 170px,249px 188px);
        }
        .b28 {
            animation: a28 5s 2s ease-in-out infinite forwards alternate;
            clip-path: polygon(184px 125px,210px 157px,186px 159px);
        }
        .b29 {
            animation: a29 5s 2s ease-in-out infinite forwards alternate;
            clip-path: polygon(184px 125px,186px 159px,152px 166px);
        }
        .b30 {
            animation: a30 5s 2s ease-in-out infinite forwards alternate;
            clip-path: polygon(165px 175px,186px 159px,152px 166px);
        }
        .b31 {
            animation: a31 5s 2s ease-in-out infinite forwards alternate;
            clip-path:polygon(165px 175px,152px 166px,133px 214px)
        }
        .b32 {
            animation: a32 5s 2s ease-in-out infinite forwards alternate;
            clip-path:polygon(152px 166px,133px 214px,155px 206px)
        }
        .b33 {
            animation: a33 5s 2s ease-in-out infinite forwards alternate ;
            clip-path:polygon(133px 214px,155px 206px,161px 232px)
        }
        .b34 {
            animation: a34 5s 2s ease-in-out infinite forwards alternate;
            clip-path:polygon(155px 206px,161px 232px,194px 213px)
        }
        .b35 {
            animation: a35 5s 2s ease-in-out infinite forwards alternate;
            clip-path:polygon(161px 232px,194px 213px,193px 231px)
        }
        .b36 {
            animation: a36 5s 2s ease-in-out infinite forwards alternate;
            clip-path:polygon(194px 213px,193px 231px,227px 240px)
        }
        @keyframes a1 {
            0%{}
            50%{
                clip-path: polygon(283px 326px,279px 352px,302px 344px);
                background-color: #54a39d;
            }
            100% {
                clip-path: polygon(176px 203px,169px 172px,207px 168px);
                background-color: #8eb0bc;
            }
        }
        @keyframes a2 {
            0%{}
            50%{
                clip-path: polygon(283px 326px,302px 344px,323px 325px);
                background-color: #469494;
            }
            100% {
                clip-path: polygon(169px 172px,207px 168px,184px 146px);
                background-color:#90a7ad ;
            }
        }
        @keyframes a3 {
            0%{}
            50%{
                clip-path: polygon(283px 326px,323px 325px,311px 301px);
                background-color: #3d878a;
            }
            100% {
                clip-path: polygon(221px 142px,207px 168px,184px 146px);
                background-color:#b1c7d2 ;
            }
        }
        @keyframes a4 {
            0%{}
            50%{
                clip-path: polygon(293px 302px,283px 326px,311px 301px);
                background-color: #65b9ac;
            }
            100% {
                clip-path: polygon(221px 142px,207px 168px,252px 167px);
                background-color:#d4dfe5 ;
            }
        }
        @keyframes a5 {
            0%{}
            50%{
                clip-path: polygon(293px 302px,311px 301px,308px 286px);
                background-color: #55a89e;
            }
            100% {
                clip-path: polygon(176px 203px,207px 168px,252px 167px);
                background-color:#1b5d6d ;
            }
        }
        @keyframes a6 {
            0%{}
            50%{
                clip-path: polygon(323px 325px,311px 301px,343px 295px);
                background-color: #2c707b;
            }
            100% {
                clip-path: polygon(176px 203px,252px 167px,197px 221px);
                background-color:#246674 ;
            }
        }
        @keyframes a7 {
            0%{}
            50%{
                clip-path: polygon(308px 286px,311px 301px,343px 295px);
                background-color: #4c9b98;
            }
            100% {
                clip-path: polygon(241px 212px,252px 167px,197px 221px);
                background-color:#246674 ;
            }
        }
        @keyframes a8 {
            0%{}
            50%{
                clip-path: polygon(308px 286px,349px 276px,343px 295px);
                background-color: #327880;
            }
            100% {
                clip-path: polygon(241px 212px,252px 167px,262px 195px);
                background-color:#4b9598 ;
            }
        }
        @keyframes a9 {
            0%{}
            50%{
                clip-path: polygon(308px 286px,349px 276px,326px 274px);
                background-color: #377d85;
            }
            100% {
                clip-path: polygon(367px 103px,359px 84px,350px 94px);
                background-color:#c55527 ;
            }
        }
        @keyframes a10 {
            0%{}
            50%{
                clip-path: polygon(350px 262px,349px 276px,326px 274px);
                background-color: #377d85;
            }
            100% {
                clip-path: polygon(332px 93px,359px 84px,350px 94px);
                background-color:#b64d20 ;
            }
        }
        @keyframes a11 {
            0%{}
            50%{
                clip-path: polygon(350px 262px,379px 236px,333px 222px);
                background-color: #aa4f3c;
            }
            100% {
                clip-path: polygon(332px 93px,359px 84px,319px 82px);
                background-color:#d8471a ;
            }
        }
        @keyframes a12 {
            0%{}
            50%{
                clip-path: polygon(309px 270px,308px 286px ,326px 276px);
                background-color: #6d002a;
            }
            100% {
                clip-path: polygon(359px 84px,319px 82px,339px 73px);
                background-color:#d84e18 ;
            }
        }
        @keyframes a13 {
            0%{}
            50%{
                clip-path: polygon(309px 270px,350px 262px ,326px 276px);
                background-color: #87172f;
            }
            100% {
                clip-path: polygon(373px 119px,365px 109px,357px 119px);
                background-color:#fffde5 ;
            }
        }
        @keyframes a14 {
            0%{}
            50%{
                clip-path: polygon(309px 270px,350px 262px ,333px 222px);
                background-color: #8c2834;
            }
            100% {
                clip-path: polygon(365px 109px,357px 119px,350px 103px);
                background-color:#e1f4f2 ;
            }
        }
        @keyframes a15 {
            0%{}
            50%{
                clip-path: polygon(309px 270px,317px 236px,333px 222px);
                background-color: #a14339;
            }
            100% {
                clip-path: polygon(343px 119px,357px 119px,350px 103px);
                background-color:#f0f2f1 ;
            }
        }
        @keyframes a16 {
            0%{}
            50%{
                clip-path: polygon(330px 212px,317px 236px,333px 222px);
                background-color: #b6613c;
            }
            100% {
                clip-path: polygon(343px 119px,350px 103px,331px 103px);
                background-color:#e8f1ec ;
            }
        }
        @keyframes a17 {
            0%{}
            50%{
                clip-path: polygon(330px 212px,363px 180px,333px 222px);
                background-color: #d08043;
            }
            100% {
                clip-path: polygon(343px 119px,331px 103px,325px 127px);
                background-color:#edf5ff ;
            }
        }
        @keyframes a18 {
            0%{}
            50%{
                clip-path: polygon(367px 202px,363px 180px,333px 222px);
                background-color: #de9247;
            }
            100% {
                clip-path: polygon(315px 114px,331px 103px,325px 127px);
                background-color:#e2e8e8 ;
            }
        }
        @keyframes a19 {
            0%{}
            50%{
                clip-path: polygon(367px 202px,379px 236px,333px 222px);
                background-color: #b9643f;
            }
            100% {
                clip-path: polygon(315px 114px,325px 127px,306px 123px);
                background-color:#eafaf9 ;
            }
        }
        @keyframes a20 {
            0%{}
            50%{
                clip-path: polygon(367px 202px,379px 236px,396px 214px);
                background-color: #cb7c43;
            }
            100% {
                clip-path: polygon(325px 127px,306px 123px,288px 171px);
                background-color:#dae1e7 ;  
            }
        }
        @keyframes a21 {
            0%{}
            50%{
                clip-path: polygon(367px 202px,403px 198px,396px 214px);
                background-color: #d68745;
            }
            100% {
                clip-path: polygon(325px 127px,335px 182px,288px 171px);
                background-color:#fd8c26 ;    
            }
        }
        @keyframes a22 {
            0%{}
            50%{
                clip-path: polygon(367px 202px,403px 198px,363px 180px);
                background-color: #eda448;
            }
            100% {
                clip-path: polygon(325px 127px,335px 182px,356px 126px);
                background-color:#fa9430 ;                                              
            }
        }
        @keyframes a23 {
            0%{}
            50%{
                clip-path: polygon(363px 180px,403px 198px,407px 183px);
                background-color: #f9b44d;
            }
            100% {
                clip-path: polygon(350px 188px,335px 182px,356px 126px);
                background-color:#bf1a07;                                                  
            }
        }
        @keyframes a24 {
            0%{}
            50%{
                clip-path: polygon(363px 180px,403px 198px,408px 163px);
                background-color: #fab74e;
            }
            100% {
                clip-path: polygon(325px 127px,356px 126px,343px 120px);
                background-color:#f5a22a;  
            }
        }
        @keyframes a25 {
            0%{}
            50%{
                clip-path: polygon(308px 267px,317px 238px,296px 226px);
                background-color: #216373;
            }
            100% {
                clip-path: polygon(357px 119px,356px 126px,343px 120px);
                background-color:#eca345;   
            }
        }
        @keyframes a26 {
            0%{}
            50%{
                clip-path: polygon(308px 267px,293px 250px,296px 226px);
                background-color: #185769;
            }
            100% {
                clip-path: polygon(373px 119px,356px 126px,357px 119px);
                background-color:#da9841;   
            }
        }
        @keyframes a27 {
            0%{}
            50%{
                clip-path: polygon(296px 226px,303px 210px,317px 238px);
                background-color: #266979;
            }
            100% {
                clip-path: polygon(288px 171px ,335px 182px,283px 226px);
                background-color:#fa7d29;           
            }
        }
        @keyframes a28 {
            0%{}
            50%{
                clip-path: polygon(332px 210px,303px 210px,317px 238px);
                background-color: #3b8689;
            }
            100% {
                clip-path: polygon(334px 219px ,335px 182px,283px 226px);
                background-color:#c92c0d;        
            }
        }
        @keyframes a29 {
            0%{}
            50%{
                clip-path: polygon(332px 210px,303px 210px,322px 201px);
                background-color: #2b8789;
            }
            100% {
                clip-path: polygon(334px 219px ,335px 182px,350px 188px);
                background-color:#c1250c;             
            }
        }
        @keyframes a30 {
            0%{}
            50%{
                clip-path: polygon(317px 196px,303px 210px,322px 201px);
                background-color: #3a8088;
            }
            100% {
                clip-path: polygon(283px 226px ,334px 219px,297px 247px);
                background-color:#d73f10;          
            }
        }
        @keyframes a31 {
            0%{}
            50%{
                clip-path: polygon(317px 196px,303px 210px,298px 196px);
                background-color: #3a8088;
            }
            100% {
                clip-path: polygon(283px 226px ,288px 171px,268px 201px);
                background-color:#fe6627;                  
            }
        }
        @keyframes a32 {
            0%{}
            50%{
                clip-path: polygon(283px 210px,303px 210px,298px 196px);
                background-color: #4c9b98;
            }
            100% {
                clip-path: polygon(283px 226px ,268px 201px,245px 219px);
                background-color:#f8601f;                   
            }
        }
        @keyframes a33 {
            0%{}
            50%{
                clip-path: polygon(283px 210px,303px 210px,284px 219px);
                background-color: #4c9b98;
            }
            100% {
                clip-path: polygon(283px 226px ,245px 219px,204px 229px);
                background-color:#f76029;                      
            }
        }
        @keyframes a34 {
            0%{}
            50%{
                clip-path: polygon(296px 226px,303px 210px,284px 219px);
                background-color: #58aba1;
            }
            100% {
                clip-path: polygon(283px 226px ,204px 229px,228px 246px);
                background-color:#f76029;                         
            }
        }
        @keyframes a35 {
            0%{}
            50%{
                clip-path: polygon(296px 226px,293px 250px,284px 219px);
                background-color: #4c9b98;
            }
            100% {
                clip-path: polygon(283px 226px ,256px 254px,228px 246px);
                background-color:#ef5a18;                                               
            }
        }
        @keyframes a36 {
            0%{}
            50%{
                clip-path: polygon(218px 215px,283px 226px,284px 219px);
                background-color: #e5fefa;
            }
            100% {
                clip-path: polygon(283px 226px ,256px 254px,297px 247px);
                background-color:#e54916;                                                  
            }
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="one b1"></div>
        <div class="one b2"></div>
        <div class="one b3"></div>
        <div class="one b4"></div>
        <div class="one b5"></div>
        <div class="one b6"></div>
        <div class="one b7"></div>
        <div class="one b8"></div>
        <div class="one b9"></div>
        <div class="one b10"></div>
        <div class="one b11"></div>
        <div class="one b12"></div>
        <div class="one b13"></div>
        <div class="one b14"></div>
        <div class="one b15"></div>
        <div class="one b16"></div>
        <div class="one b17"></div>
        <div class="one b18"></div>
        <div class="one b19"></div>
        <div class="one b20"></div>
        <div class="one b21"></div>
        <div class="one b22"></div>
        <div class="one b23"></div>
        <div class="one b24"></div>
        <div class="one b25"></div>
        <div class="one b26"></div>
        <div class="one b27"></div>
        <div class="one b28"></div>
        <div class="one b29"></div>
        <div class="one b30"></div>
        <div class="one b31"></div>
        <div class="one b32"></div>
        <div class="one b33"></div>
        <div class="one b34"></div>
        <div class="one b35"></div>
        <div class="one b36"></div>
    </div>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值