更多课程 选择中心


Web培训

400-111-8989

Web培训

纯CSS3白云飘动背景特效代码

  • 发布:佚名
  • 来源:网络
  • 时间:2015-10-23 17:02

这是一款非常简单的纯CSS3白云飘动背景特效。该白云飘动特效使用CSS animation动画来控制不同的白云,以不同的速度进行运动,形成白云飘动的效果。

纯CSS3白云飘动背景

使用方法

HTML结构

<div id="clouds">

	  <div class="cloud x1"></div>

	  <div class="cloud x2"></div>

	  <div class="cloud x3"></div>

	  <div class="cloud x4"></div>

	  <div class="cloud x5"></div>

	</div>

该白云飘动特效的HTML结果非常简单,使用一个div来包裹一组作为白云的div元素。

CSS样式

白云使用.cloud 和它的:before和:after伪元素来制作。

	.cloud {

	  width: 200px; height: 60px;

	  background: #fff;

	    

	  border-radius: 200px;

	  -moz-border-radius: 200px;

	  -webkit-border-radius: 200px;

	    

	  position: relative;

	}

	  

	.cloud:before, .cloud:after {

	  content: '';

	  position: absolute;

	  background: #fff;

	  width: 100px; height: 80px;

	  position: absolute; top: -15px; left: 10px;

	    

	  border-radius: 100px;

	  -moz-border-radius: 100px;

	  -webkit-border-radius: 100px;

	    

	  -webkit-transform: rotate(30deg);

	  transform: rotate(30deg);

	  -moz-transform: rotate(30deg);

	}

	  

	.cloud:after {

	  width: 120px; height: 120px;

	  top: -55px; left: auto; right: 15px;

	}

每一朵白云都执行moveclouds动画,但是它们的动画速度各不相同。大小和透明度也各不相同。

	.x1 {

	  -webkit-animation: moveclouds 15s linear infinite;

	  -moz-animation: moveclouds 15s linear infinite;

	  -o-animation: moveclouds 15s linear infinite;

	}

	.x2 {

	  left: 200px;

	    

	  -webkit-transform: scale(0.6);

	  -moz-transform: scale(0.6);

	  transform: scale(0.6);

	  opacity: 0.6; /*opacity proportional to the size*/

	    

	  /*Speed will also be proportional to the size and opacity*/

	  /*More the speed. Less the time in 's' = seconds*/

	  -webkit-animation: moveclouds 25s linear infinite;

	  -moz-animation: moveclouds 25s linear infinite;

	  -o-animation: moveclouds 25s linear infinite;

	}

	......

	@-webkit-keyframes moveclouds {

	  0% {margin-left: 1000px;}

	  100% {margin-left: -1000px;}

	}

	@-moz-keyframes moveclouds {

	  0% {margin-left: 1000px;}

	  100% {margin-left: -1000px;}

	}

	@-o-keyframes moveclouds {

	  0% {margin-left: 1000px;}

	  100% {margin-left: -1000px;}

	}

推荐:jQlouds是一款非常有趣的可以制作天空中白云飘动特效的jQuery插件。天空中白云朵朵,你可以通过这个插件来设置云朵的大小、位置、模糊以及被风吹动的效果。

预约申请免费试听课

填写下面表单即可预约申请免费试听! 怕学不会?助教全程陪读,随时解惑!担心就业?一地学习,可全国推荐就业!

上一篇:12 个 CSS 高级技巧汇总
下一篇:如何通过预加载器提升网页加载速度

纯CSS3 steps属性打造炫酷西洋镜动画

CSS3中的隐藏的10个特性

纯CSS3带阴影效果的剪纸文字动画特效

纯CSS3白云飘动背景特效代码

  • 扫码领取资料

    回复关键字:视频资料

    免费领取 达内课程视频学习资料

Copyright © 2023 Tedu.cn All Rights Reserved 京ICP备08000853号-56 京公网安备 11010802029508号 达内时代科技集团有限公司 版权所有

选择城市和中心
黑龙江省

吉林省

河北省

贵州省

云南省

广西省

海南省