纯CSS实现超真实的动态云朵效果

纯CSS实现超真实的动态云朵效果

这是一款效果非常炫酷的纯CSS3逼真的多层云彩动画特效。该特效使用多张透明的云彩图片作为背景图片,使用CSS animation动画来制作云彩水平飘动的动画效果。

  • 效果展示

在这里插入图片描述

  • 代码实现
    • 目录结构:
      在这里插入图片描述

    • HTML:

      <!doctype html>
      <html lang="zh">
      <!--
      author: ghp
      date: 2022/10/12
      description: 纯CSS实现的超真实的动态云朵效果
      -->
      <head>
      	<meta charset="UTF-8">
      	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
      	<meta name="viewport" content="width=device-width, initial-scale=1.0">
      	<title>纯CSS3打造超真实的多层云彩动画特效</title>
      	<link rel="stylesheet" href="./css/cloud.css">
      </head>
      
      <body>
      	<div class="htmleaf-container">
      		<div class="sky">
      			<div class="clouds_one"></div>
      			<div class="clouds_two"></div>
      			<div class="clouds_three"></div>
      		</div>
      	</div>
      </body>
      
      </html>
      
    • CSS:

      html,
      body {
          margin: 0;
          height: 100%
      }
      
      .sky {
          height: 100vh;
          background: #007fd5;
          position: relative;
          overflow: hidden;
          -webkit-animation: sky_background 50s ease-out infinite;
          -moz-animation: sky_background 50s ease-out infinite;
          -o-animation: sky_background 50s ease-out infinite;
          animation: sky_background 50s ease-out infinite;
          -webkit-transform: translate3d(0, 0, 0);
          -ms-transform: translate3d(0, 0, 0);
          -o-transform: translate3d(0, 0, 0);
          transform: translate3d(0, 0, 0);
      }
      
      .clouds_one {
          background: url("../img/cloud_one.png");
          position: absolute;
          left: 0;
          top: 0;
          height: 100%;
          width: 300%;
          -webkit-animation: cloud_one 50s linear infinite;
          -moz-animation: cloud_one 50s linear infinite;
          -o-animation: cloud_one 50s linear infinite;
          animation: cloud_one 50s linear infinite;
          -webkit-transform: translate3d(0, 0, 0);
          -ms-transform: translate3d(0, 0, 0);
          -o-transform: translate3d(0, 0, 0);
          transform: translate3d(0, 0, 0);
      }
      
      .clouds_two {
          background: url("../img/cloud_two.png");
          position: absolute;
          left: 0;
          top: 0;
          height: 100%;
          width: 300%;
          -webkit-animation: cloud_two 75s linear infinite;
          -moz-animation: cloud_two 75s linear infinite;
          -o-animation: cloud_two 75s linear infinite;
          animation: cloud_two 75s linear infinite;
          -webkit-transform: translate3d(0, 0, 0);
          -ms-transform: translate3d(0, 0, 0);
          -o-transform: translate3d(0, 0, 0);
          transform: translate3d(0, 0, 0);
      }
      
      .clouds_three {
          background: url("../img/cloud_three.png");
          position: absolute;
          left: 0;
          top: 0;
          height: 100%;
          width: 300%;
          -webkit-animation: cloud_three 100s linear infinite;
          -moz-animation: cloud_three 100s linear infinite;
          -o-animation: cloud_three 100s linear infinite;
          animation: cloud_three 100s linear infinite;
          -webkit-transform: translate3d(0, 0, 0);
          -ms-transform: translate3d(0, 0, 0);
          -o-transform: translate3d(0, 0, 0);
          transform: translate3d(0, 0, 0);
      }
      
      @-webkit-keyframes sky_background {
          0% {
              background: #007fd5;
              color: #007fd5
          }
      
          50% {
              background: #000;
              color: #a3d9ff
          }
      
          100% {
              background: #007fd5;
              color: #007fd5
          }
      }
      
      @-moz-keyframes sky_background {
          0% {
              background: #007fd5;
              color: #007fd5
          }
      
          50% {
              background: #000;
              color: #a3d9ff
          }
      
          100% {
              background: #007fd5;
              color: #007fd5
          }
      }
      
      @keyframes sky_background {
          0% {
              background: #007fd5;
              color: #007fd5
          }
      
          50% {
              background: #000;
              color: #a3d9ff
          }
      
          100% {
              background: #007fd5;
              color: #007fd5
          }
      }
      
      @-webkit-keyframes cloud_one {
          0% {
              left: 0
          }
      
          100% {
              left: -200%
          }
      }
      
      @-moz-keyframes cloud_one {
          0% {
              left: 0
          }
      
          100% {
              left: -200%
          }
      }
      
      @keyframes cloud_one {
          0% {
              left: 0
          }
      
          100% {
              left: -200%
          }
      }
      
      @-webkit-keyframes cloud_two {
          0% {
              left: 0
          }
      
          100% {
              left: -200%
          }
      }
      
      @-moz-keyframes cloud_two {
          0% {
              left: 0
          }
      
          100% {
              left: -200%
          }
      }
      
      @keyframes cloud_two {
          0% {
              left: 0
          }
      
          100% {
              left: -200%
          }
      }
      
      @-webkit-keyframes cloud_three {
          0% {
              left: 0
          }
      
          100% {
              left: -200%
          }
      }
      
      @-moz-keyframes cloud_three {
          0% {
              left: 0
          }
      
          100% {
              left: -200%
          }
      }
      
      @keyframes cloud_three {
          0% {
              left: 0
          }
      
          100% {
              left: -200%
          }
      }
      

附赠img图片:
在这里插入图片描述

cloud_one
cloud_three
cloud_two

PS: 如果对您有帮助,欢迎三连(关注💖、点赞👍、收藏⭐)

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
以下是一个CSS实现一片渐变叶子的例子: HTML代码: ```html <div class="leaf"></div> ``` CSS代码: ```css .leaf { width: 0; height: 0; border-top: 50px solid transparent; border-bottom: 50px solid transparent; border-right: 100px solid #5cb85c; background: linear-gradient(to bottom, #5cb85c 0%, #4cae4c 100%); position: relative; transform: rotate(45deg); } .leaf:before { content: ""; position: absolute; top: -25px; left: -25px; width: 0; height: 0; border-top: 50px solid transparent; border-bottom: 50px solid transparent; border-right: 100px solid #5cb85c; transform: rotate(-45deg); } .leaf:after { content: ""; position: absolute; top: -25px; left: 25px; width: 0; height: 0; border-top: 50px solid transparent; border-bottom: 50px solid transparent; border-left: 100px solid #4cae4c; transform: rotate(45deg); } ``` 解释: 这个例子中,我们使用了三个伪元素来实现一片叶子的效果。其中,主要的叶子元素是一个长方形,通过`border`属性来定义了其形状。我们使用了`linear-gradient`属性来实现渐变效果,从上到下从浅绿色渐变到深绿色。通过`transform`属性的`rotate`函数,我们将叶子旋转了45度。 接下来,我们使用了两个伪元素,分别在叶子的左上角和右上角创建了两个三角形,用于填补叶子的两个角落。这两个三角形也是通过`border`属性来定义的,同样使用`transform: rotate()`函数来旋转至正确的位置。 最终的效果如下图所示: ![渐变叶子效果](https://cdn.jsdelivr.net/gh/0xAiKang/CDN/pictures/gradient-leaf.png)

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

知识汲取者

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值