Pure CSS to achieve cloudy weather icon effect

Pure CSS to achieve cloudy weather icon effect

Effect

The effect is as follows

Implementation ideas

  1. Use the box-shadow property to draw several gray circles and combine them together to form a dark cloud pattern.
  2. after pseudo-element writes the shadow under the dark clouds
  3. Add animation

DOM structure

Use two nested div containers. The parent container controls the display position of the icon, and the child container is used to write the style of the dark clouds.

<div class="container">
    <div class="cloudy"></div>
</div>

CSS Styles

1. Parent container style, add a background color to the entire page for easy preview

body{
    background: rgba(73, 74, 95, 1);
}
.container{
    width: 170px;
    height: 170px;
    position: relative;
    margin: 250px auto;
}

2. The style of dark clouds, the dark clouds have an animation of moving up and down. The key here is the use of the box-shadow property. If it is white, it can be used as a cloudy weather icon.

.cloudy{
    width: 50px;
    height: 50px;
    position: absolute;
    top: 70px;
    left: 80px;
    margin-left: -60px;
    background: #ccc;
    border-radius: 50%;
    box-shadow: #ccc 65px -10px 0 -5px,
        #ccc 25px -25px,
        #ccc 30px 10px,
        #ccc 60px 15px 0 -10px,
        #ccc 85px 5px 0 -5px;
    animation: cloudy 5s ease-in-out infinite;
}
@keyframes cloudy{
    50%{
        transform: translateY(-20px);
    }
}

3. For the projection style, you can use the after pseudo element. Don’t forget that there is also a moving animation.

.cloudy::after{
    content: '';
    width: 120px;
    height: 15px;
    position: absolute;
    bottom: -60px;
    left: 5px;
    background: #000;
    border-radius: 50%;
    opacity: 0.2;
    animation: cloudy-shadow 5s ease-in-out infinite;
    transform: scale(0.7);
}

@keyframes cloudy-shadow
    50%{
        transform: translateY(20px) scale(1);
        opacity: 0.05;
    }
}

OK, done. Follow the steps and you can also implement the cloudy weather icon on your page~

Summarize

The above is the pure CSS that I introduced to you to achieve the cloudy weather icon effect. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

<<:  10 skills that make front-end developers worth millions

>>:  Solution to Django's inability to access static resources with uwsgi+nginx proxy

Recommend

Detailed explanation of setting Context Path in Web application

URL: http://hostname.com/contextPath/servletPath/...

How to write a MySQL backup script

Preface: The importance of database backup is sel...

Introduction to cloud native technology kubernetes (K8S)

Table of contents 01 What is Kubernetes? 02 The d...

Vue complete code to implement single sign-on control

Here is a Vue single sign-on demo for your refere...

Using HTML+CSS to track mouse movement

As users become more privacy-conscious and take m...

Solution to the problem of failure to insert emoji expressions into MySQL

Preface I always thought that UTF-8 was a univers...

How complicated is the priority of CSS styles?

Last night, I was looking at an interview question...

How to draw a cool radar chart in CocosCreator

Table of contents Preface Preview text Graphics C...

HTML page jump and parameter transfer issues

HTML page jump: window.open(url, "", &q...

Detailed explanation of how to quickly build a blog website using Docker

Table of contents 1. Preparation 2. Deployment Pr...

Example code for implementing image adaptive container with CSS

There is often a scenario where the image needs t...

How to use a field in one table to update a field in another table in MySQL

1. Modify 1 column update student s, city c set s...