css实现三角广告横幅文字彩旗旗帜随风摆动飘动动画效果代码

代码语言:html

所属分类:动画

代码描述:css实现三角广告横幅文字彩旗旗帜随风摆动飘动动画效果代码

代码标签: css 三角 旗帜 彩旗 文字 广告 横幅

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">


    <meta name="viewport" content="width=800, initial-scale=1">
 



    <style>
        .banner {
          width: 800px;
          height: 100px;
          border: 0px dotted cyan;
          position: relative;
          transform-style: preserve-3d;
          transform: var(--transform);
          --transform: scale(1);
          display: none;
        }
        .banner {
          display: flex;
          justify-content: space-between;
        }
        .flag {
          display: flex;
          height: 70px;
          width: 45px;
          background: hsl(var(--hue,43), 90%, 55%);
          color: hsl(43, 90%, var(--text,5%));
          clip-path: polygon(0% 0%, 100% 0%, 50% 100%);
          transform-origin: 50% 0%;
          
          justify-content: center;
          align-items: center;
          padding-bottom: 1rem;
        }
        .string {
          display: none;
        }
        .flag:nth-of-type(odd) {
          --hue: 343;
          --text: 95%;
        }
        .banner:nth-of-type(even) .flag:nth-of-type(even) {
          --hue: 333;
        }
        .banner:nth-of-type(even) .flag:nth-of-type(odd) {
          --hue: 193;
        }
        .banner:nth-of-type(3) .flag:nth-of-type(odd) {
          --hue: 33;
        }
        .banner:nth-of-type(3) .flag:nth-of-type(even) {
          --hue: 173;
        }
        
        @supports (offset-path: path('M0,0 C100,100 700,200 800,100')) {
          .banner {
            height: 230px;
          }
          .banner:nth-of-type(even) {
            --transform: rotate(0deg);
          }
          .banner:nth-of-type(2) {
            --transform: scaleX(-1) rotate(-8deg);
          }
          .banner:nth-of-type(1) {
            --transform: rotate(-4deg);
          }
          .flag:not(.string) {
            position: absolute;
            offset-anchor: 50% 0%;
            offset-path: path('M0,0 C100,100 700,200 800,100');
          }
        }
        
        @supports (d: path('M0,0 C100,100 700,200 800,100')) {
          .string,
          .string svg {
            position: absolute;
            width: 800px;
            top: 0;
            left: 0;
            height: 230px;
            display: block;
            background: transparent;
            clip-path: none;
          }
          .string path {
            stroke: hsla(183, 20%, 30%, .3);
            stroke-width: 1px;
            d: path('M0,0 C100,100 700,200 800,100');
          }
        }
        
        body {
          height: 100vh;
          display: flex;
          justify-content: center;
          align-items: center;
          flex-direction: column;
          overflow: hidden;
          perspective: 700px;
          background: hsl(183, 100%, 95.25%);
          
        }
        *, *::before, *::after {
          box-sizing: border-box;
        }
    </style>

 

</head>

<body>
    <h1 class="banner">
        <span class="flag"></span>
        <span class="flag"></span>
        <span class="flag">H</span>
        <span class="flag">U</span>
        <span class="flag">Z</span>
        <span class="flag">Z</span>
        <span class="flag">A</span>
        <span class="flag">H</span>
        <span class="flag">!</span>
        <span class="flag"></span>
        <span class="string">
    <svg width="800" height="230" viewBox="0 0 800 230">
      <path fill="none" d="M0,0 C100,100 700,200 800,100" />
    </svg>
  </span>
    </h1>

    <h1 class="banner">
        <span class="flag"></span>
        <span class="flag"></span>
        <span class="flag"></span>
        <span class="flag"></span>
        <span class="flag"></span>
        <span class="flag"></span>
        <span class="fl.........完整代码请登录后点击上方下载按钮下载查看

网友评论0