首页 > 其他分享 >CSS制作逼真的波浪效果

CSS制作逼真的波浪效果

时间:2023-10-14 23:33:33浏览次数:30  
标签:use 逼真 100% 波浪 height animation parallax child CSS

效果

代码示例

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <link rel="icon" href="/favicon.ico" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <meta name="keywords" content="keywords" />
  <meta name="description" content="description" />
  <title>%VITE_APP_TITLE%</title>
</head>
<body>
  <div id="app">
    <style>
      html,
      body {
        height: 100%;
        margin: 0;
        min-height: 100%;
      }

      .container {
        background: linear-gradient(60deg, rgba(84, 58, 183, 1) 0%, rgba(0, 172, 193, 1) 100%);
      }

      .content {
        height: 65vh;
        width: 100%;
        margin: 0;
        padding: 0;
      }

      .waves {
        position: relative;
        width: 100%;
        height: 15vh;
        margin-bottom: -7px;
        /* 修复 Safari 等浏览器下方空隙 */
        min-height: 100px;
        max-height: 150px;
      }

      /* 动画 */
      .parallax>use {
        animation: move-forever 25s cubic-bezier(0.55, 0.5, 0.45, 0.5) infinite;
      }

      .parallax>use:nth-child(1) {
        animation-delay: -2s;
        animation-duration: 7s;
      }

      .parallax>use:nth-child(2) {
        animation-delay: -3s;
        animation-duration: 10s;
      }

      .parallax>use:nth-child(3) {
        animation-delay: -4s;
        animation-duration: 13s;
      }

      .parallax>use:nth-child(4) {
        animation-delay: -5s;
        animation-duration: 20s;
      }

      @keyframes move-forever {
        0% {
          transform: translate3d(-90px, 0, 0);
        }

        100% {
          transform: translate3d(85px, 0, 0);
        }
      }
    </style>
    <div class="container">
      <div class="content"></div>
      <svg class="waves" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
        viewBox="0 24 150 28" preserveAspectRatio="none" shape-rendering="auto">
        <defs>
          <path id="gentle-wave" d="M-160 44c30 0 58-18 88-18s 58 18 88 18 58-18 88-18 58 18 88 18 v44h-352z" />
        </defs>
        <g class="parallax">
          <use xlink:href="#gentle-wave" x="48" y="0" fill="rgba(255,255,255,0.7" />
          <use xlink:href="#gentle-wave" x="48" y="3" fill="rgba(255,255,255,0.5)" />
          <use xlink:href="#gentle-wave" x="48" y="5" fill="rgba(255,255,255,0.3)" />
          <use xlink:href="#gentle-wave" x="48" y="7" fill="#fff" />
        </g>
      </svg>
    </div>
  </div>
  <!-- <script type="module" src="/src/main.js"></script> -->
</body>
</html>

标签:use,逼真,100%,波浪,height,animation,parallax,child,CSS
From: https://www.cnblogs.com/echohye/p/17764960.html

相关文章

  • css 10-13
    1.背影样式 backgroud-color          背景颜色backgroud-color:red backgroud-image         背景图片backgroud-image backgroud-position        背景图片位置backgroud-positiontop  left ......
  • 前端面试题之CSS
    一、CSS基础1.对盒模型的理解CSS3中的盒模型有以下两种:标准盒子模型、IE盒子模型盒模型都是由四个部分组成的,分别是margin、border、padding和content。标准盒模型和IE盒模型的区别在于设置width和height时,所对应的范围不同:标准盒模型的width和height属性的范围只包含了content,IE盒......
  • css-图片和文字小模块
    <!DOCTYPEhtml><htmllang="zh"> <head> <metacharset="UTF-8"> <metaname="viewport"content="width=device-width,initial-scale=1.0"> <title>Document</title> <sc......
  • CSS-02
    Emmet语法提高编写速度HTML生成标签:标签名+tab建多个相同标签:div*3(生成3组)父子关系:ul>lidiv>span兄弟关系:div+p有class或id的标签名:p.nav或p#nav有顺序的类名:.demo$5生成的标签内有内容:div{内容}CSStext-align:center=tactext-indent:=tiwidth:200=w200text-decorat......
  • 【前端开发】前端使用Tailwind CSS写样式效率翻倍
    vite+Vue项目配置教程配置地址:https://tailwind.nodejs.cn/docs/guides/vite中文文档:https://tailwind.nodejs.cn/docs/installation说明:使用TailwindCSS可省略写繁琐的css代码,通过用class快速布局,如下图页面全是class,很少会写css代码。 例子:创建variable.css文件,代码如下......
  • CSS高度单位
    line-height属性的细节 (子元素继承父元素系数)与大多数CSS属性不同,line-height支持属性值设置为无单位的数字。有无单位在子元素继承属性时有微妙的不同。语法line-height:normal|<number>|<length>|<percentage>normal根据浏览器决定,一般为1.2。number仅指定数字......
  • html5+css3
    一、HTML1、浏览器内核又可以分成两部分:渲染引擎(layoutengineer)和JS引擎(renderingengine)后来的JS的发展独立出来,常用5大浏览器分别是:IE(edge)、Chrome、Firefox、Safari、opera。浏览器内核有那些?分别被使用在那些浏览器?Trident(IE)国内很多双核浏览器其中一核就是trident......
  • 【前端css】全局修改css让网页置灰,去掉色彩
    html{filter:grayscale(100%);//IE浏览器-webkit-filter:grayscale(100%);//谷歌浏览器-moz-filter:grayscale(100%);//火狐-ms-filter:grayscale(100%);-o-filter:grayscale(100%);filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);......
  • 【vue2】实现css动效逐个顺序展示的效果(简陋版)
    效果(进入预约里程碑模块后,小人从第一个台阶逐个闪烁出现在当前预约等级之前的台阶并消失,最终停留在当前预约等级的台阶上): 虽然很low但是!就是这么设计的!于是在原本静态的代码上稍加了些修改(为什么,为什么,想问天问大地)首先是台阶部分的代码:<div:class="$style.reserveBox......
  • S12700 CSS主备倒换
    导致集群主备倒换的原因较多,在此主要介绍由于主控板故障引起的主备倒换以及通过命令行执行的主备倒换。主控板故障引起的主备倒换集群系统主控板的故障可能会引起集群系统内角色的变化。集群系统主用主控板故障集群系统主用主控板故障后,集群系统角色的变化如图3-21所示。图3-21 集......