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

Native js to implement a simple calculator

This article example shares the specific code of ...

How to build LNMP environment on Ubuntu 20.04

Simple description Since it was built with Centos...

CSS3 uses the transition property to achieve transition effects

Detailed description of properties The purpose of...

Solution to the problem that mysql local login cannot use port number to log in

Recently, when I was using Linux to log in locall...

Box-shadow and drop-shadow to achieve irregular projection example code

When we want to add a shadow to a rectangle or ot...

Answers to several high-frequency MySQL interview questions

Preface: In interviews for various technical posi...

MySQL 8.0.21 installation and configuration method graphic tutorial

Record the installation and configuration method ...

WeChat applet wxs date and time processing implementation example

Table of contents 1. Timestamp to date 2. Convert...

Solution to the problem that the InnoDB engine is disabled when MySQL is started

Find the problem Today at work, when copying tabl...

A brief discussion on macrotasks and microtasks in js

Table of contents 1. About JavaScript 2. JavaScri...

Using puppeteer to implement webpage screenshot function on linux (centos)

You may encounter the following problems when ins...

Detailed explanation of the cache implementation principle of Vue computed

Table of contents Initialize computed Dependency ...