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

How to install the graphical interface in Linux

1. Linux installation (root user operation) 1. In...

Vue uses mockjs to generate simulated data case details

Table of contents Install mockjs in your project ...

Summary of Common Mistakes in Web Design

In the process of designing a web page, designers...

Build a WebRTC video chat in 5 minutes

In the previous article, I introduced the detaile...

Sample code using the element calendar component in Vue

First look at the effect diagram: The complete co...

Independent implementation of nginx container configuration file

Create a container [root@server1 ~]# docker run -...

ReactJs Basics Tutorial - Essential Edition

Table of contents 1. Introduction to ReactJS 2. U...

A practical record of checking and processing duplicate MySQL records on site

Table of contents Preface analyze Data Total Repe...

The difference between div and table in speed, loading, web application, etc.

1: Differences in speed and loading methods The di...

Summary of JavaScript custom object methods

Table of contents 1. Use object to create an obje...

25 Tools to Improve Website Usability and Conversion Rates

For a website, usability refers to whether users c...

mysql join query (left join, right join, inner join)

1. Common connections for mysql INNER JOIN (inner...