CSS3 to achieve simple white cloud floating background effect

CSS3 to achieve simple white cloud floating background effect

This is a very simple pure CSS3 white cloud floating background effect. The floating white clouds special effect uses CSS animation to control different white clouds, moving at different speeds to create the effect of floating white clouds.

HTML Structure

The HTML result of this white cloud floating effect is very simple. A <div> is used to wrap a group of <div> elements as white clouds.

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

The white clouds are created using .cloud and its :before and :after pseudo-elements.

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

Each cloud executes the moveclouds animation, but they animate at different speeds. Size and transparency also vary.

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

The above is the details of how to use CSS3 to achieve a simple white cloud floating background effect. For more information about CSS3 special effects, please pay attention to other related articles on 123WORDPRESS.COM!

<<:  Causes and solutions for front-end exception 502 bad gateway

>>:  9 Practical CSS Properties Web Front-end Developers Must Know

Recommend

Vue components dynamic components detailed explanation

Table of contents Summarize Summarize When the ar...

Why node.js is not suitable for large projects

Table of contents Preface 1. Application componen...

LINUX Checks whether the port is occupied

I have never been able to figure out whether the ...

Tutorial on installing MySQL with Docker and implementing remote connection

Pull the image docker pull mysql View the complet...

Implementation of MySQL master-slave status check

1. Check the synchronization status of A and B da...

UTF-8 and GB2312 web encoding

Recently, many students have asked me about web p...

Example of implementing dynamic verification code on a page using JavaScript

introduction: Nowadays, many dynamic verification...

Linux firewall iptables detailed introduction, configuration method and case

1.1 Introduction to iptables firewall Netfilter/I...

MySQL data analysis storage engine example explanation

Table of contents 1. Introduce cases 2. View the ...

MySQL database table partitioning considerations [recommended]

Table partitioning is different from database par...

WeChat applet learning notes: page configuration and routing

I have been studying and reviewing the developmen...

Two query methods when the MySQL query field type is json

The table structure is as follows: id varchar(32)...

How to directly reference vue and element-ui in html

The code looks like this: <!DOCTYPE html> &...