css3实现简单的白云飘动背景特效

  发布时间:2020-10-28 17:26:30   作者:蚂蚁开源社区   我要评论
这篇文章主要介绍了css3实现简单的白云飘动背景特效的示例,帮助大家制作网页特效,美化自己的网站,感兴趣的朋友可以了解下
(福利推荐:【腾讯云】服务器最新限时优惠活动,云服务器1核2G仅99元/年、2核4G仅768元/3年,立即抢购>>>:9i0i.cn/qcloud

(福利推荐:你还在原价购买阿里云服务器?现在阿里云0.8折限时抢购活动来啦!4核8G企业云服务器仅2998元/3年,立即抢购>>>:9i0i.cn/aliyun

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

HTML结构

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

<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>

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;}
}

以上就是css3实现简单的白云飘动背景特效的详细内容,更多关于CSS3特效的资料请关注程序员之家其它相关文章!

相关文章

  • css3实现背景图片半透明内容不透明的方法示例

    这篇文章主要介绍了css3实现背景图片半透明内容不透明的方法示例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小
    2021-04-13
  • css3实现背景图片颜色修改的多种方式

    这篇文章主要介绍了css3实现背景图片颜色修改的多种方式,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起
    2021-04-13
  • css3制作的背景渐变动画效果

    这篇文章主要介绍了css3实现的加载动画效果,帮助大家更好的利用css3制作网页,感兴趣的朋友可以了解下
    2021-04-07
  • CSS3实现模糊背景的三种效果示例

    这篇文章主要介绍了CSS3实现模糊背景的三种效果示例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习
    2021-03-29
  • CSS3 菱形拼图实现只旋转div 背景图片不旋转功能

    这篇文章主要介绍了CSS3 菱形拼图实现只旋转div 背景图片不旋转功能,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
    2021-03-29
  • CSS3只让背景图片旋转180度的实现示例

    这篇文章主要介绍了CSS3只让背景图片旋转180度的实现示例。文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一
    2021-03-09
  • 基于css3制作的圆形透明画中画视频播放特效

    圆形透明画中画视频播放特效是一款基于css3制作的创意透明圆形层mp4视频播放特效代码。
    2020-12-17
  • JS+CSS3文章内容背景黑白切换特效代码

    JS+CSS3文章内容背景黑白切换特效代码是一款基于JS+CSS3制作的简单网页文章文字内容背景颜色黑白切换效果。
    2020-11-27
  • CSS3 实现的动态星空背景

    这篇文章主要介绍了CSS3 实现的动态星空背景的示例代码,帮助大家更好的理解和学习制作CSS3特效,感兴趣的朋友可以了解下
    2021-04-22

最新评论

?


http://www.vxiaotou.com