• 纯 CSS 创作出平滑的层叠海浪特效


    这里的波浪只是侧面的,利用几个平面一部分弧旋转得到。

    代码解读

    定义 dom,容器中包含一行文本和3条做海浪特效的 <span>:

    <div class="sea">
        <p class="title">the sea</p>
        <span class="wave"></span>
        <span class="wave"></span>
        <span class="wave"></span>
    </div>
    

      

    居中显示:

    html, body {
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        background: linear-gradient(antiquewhite, navajowhite);
    }
    

      

    设置容器样式:

    .sea {
         300px;
        height: 300px;
        background-color: whitesmoke;
        background-image: linear-gradient(
            darkblue,
            rgba(255, 255, 255, 0) 80%,
            rgba(255, 255, 255, 0.5));
        border-radius: 5px;
        box-shadow: 0 2px 30px rgba(0, 0, 0, 0.2);
    }
    

      

    设置文字样式:

    .sea {
        position: relative;
    }
    
    .sea .title {
        color: white;
        font-size: 24px;
        font-family: serif;
        text-align: center;
        line-height: 250px;
        text-transform: uppercase;
        letter-spacing: 0.4em;
        position: absolute;
        z-index: 1;
         100%;
    }
    

      

    制作海浪动画效果:

    .sea .wave {
        position: absolute;
        top: -250px;
        left: -100px;
         500px;
        height: 500px;
        background: deepskyblue;
        border-radius: 43%;
        filter: opacity(0.4);
        animation: drift linear infinite;
    }
    
    .sea .wave:nth-of-type(1) {
        animation-duration: 5s;
    }
    
    .sea .wave:nth-of-type(2) {
        animation-duration: 7s;
    }
    
    .sea .wave:nth-of-type(3) {
        animation-duration: 9s;
    }
    
    @keyframes drift {
        from {
            transform: rotate(360deg);
        }
    }
    

    广州vi设计http://www.maiqicn.com 办公资源网站大全 https://www.wode007.com

    加大海浪的波动幅度,增加颜色差异:

    .sea .wave {
        transform-origin: 50% 48%;
    }
    
    .sea .wave:nth-of-type(3) {
        background-color: orangered;
        filter: opacity(0.1);
    }
    

      

    最后,隐藏容器外的内容:

     
    .sea {
        overflow: hidden;
    }
    

      

    大功告成!

  • 相关阅读:
    POJ 1330:Nearest Common Ancestors【lca】
    图论中一类问题的总结 :必须边(点) 可行边(点)
    POJ 1486 Sorting Slides【二分图匹配】
    POJ 2375 Cow Ski Area【tarjan】
    Unity打开AppStore进行评论
    Unity3D UGUI不规则图片点击事件处理
    Unity3D之聊天框怎么跟随内容大小而变换
    Unity3D之小物体层消隐技术
    Unity3D之新手引导(责任链模式)
    Unity3D之FSM有限状态机
  • 原文地址:https://www.cnblogs.com/ypppt/p/13683479.html
Copyright © 2020-2023  润新知