CSS3 realizes the animation effect of lotus blooming

CSS3 realizes the animation effect of lotus blooming

Let’s look at the effect first:

This effect looks quite dazzling, but the principle is not complicated. If one petal can be moved, then all nine petals can be made. It's just a superposition of effects.

HTML:

<section class="demo">  
  <div class="box">  
     <div class="leaf"></div>  
     <div class="leaf"></div>  
     <div class="leaf"></div>  
     <div class="leaf"></div>  
     <div class="leaf"></div>  
     <div class="leaf"></div> 
     <div class="leaf"></div>  
     <div class="leaf"></div>  
     <div class="leaf"></div>  
  </div>  
</section>

CSS:

View Code 
body {
   background-color: #000;
}      

.demo {
   margin:0px auto;
   width: 500px;
}
/*Container for lotus petals*/
.box {
   position: relative;/*Set relative positioning, because the petals must be absolutely positioned*/   
   height: 400px;
   margin-top:400px
}
/*Absolute positioning of petals*/
.box .leaf {
   position: absolute;
}
/*Draw lotus petals*/
.leaf {
   margin-top:0px;
   width: 200px;
   height: 200px;
   border-radius: 200px 0px;/*Make petal corners*/
   background: -moz-linear-gradient(45deg,rgba(188,190,192,1) 8%,rgba(158,31,99,1) 30%,rgba(158,31,99,1) 100%);/*Make petal color*/
        background: -webkit-linear-gradient(45deg,rgba(188,190,192,1) 8%,rgba(158,31,99,1) 30%,rgba(158,31,99,1) 100%);/*Make petal color*/
   opacity: .6;
   filter:alpha(opacity=50);
   transform: rotate(135deg);/*petals rotate 135deg*/
   transform-origin: top right;/*Reset the petal rotation origin, this is very important*/
}

@keyframes show-2 {
    0% {
     transform: rotate(135deg);
    }
    50% {
     transform: rotate(45deg);
    }
    100%{
     transform: rotate(135deg);
    }
}
@keyframes show-3 {
    0% {
     transform: rotate(135deg);
    }
    50% {
     transform: rotate(65deg);
    }
    100%{
     transform: rotate(135deg);
    }
}
@keyframes show-4 {
    0% {
     transform: rotate(135deg);
    }
    50% {
     transform: rotate(85deg);
    }
    100%{
     transform: rotate(135deg);
    }
}
@keyframes show-5 {
    0% {
     transform: rotate(135deg);
    }
    50% {
     transform: rotate(105deg);
    }
    100%{
     transform: rotate(135deg);
    }
}
@keyframes show-6 {
    0% {
     transform: rotate(135deg);
    }
    50% {
     transform: rotate(165deg);
    }
    100%{
     transform: rotate(135deg);
    }
}
@keyframes show-7 {
    0% {
     transform: rotate(135deg);
    }
    50% {
     transform: rotate(185deg);
    }
    100%{
     transform: rotate(135deg);
    }
}
@keyframes show-8 {
    0% {
     transform: rotate(135deg);
    }
    50% {
     transform: rotate(205deg);
    }
    100%{
     transform: rotate(135deg);
    }
}  

@keyframes show-9 {
    0% {
     transform: rotate(135deg);
    }
    50% {
     transform: rotate(225deg);
    }
    100%{
     transform: rotate(135deg);
    }
}  

.leaf:nth-child(1) {
 background: -moz-linear-gradient(45deg,rgba(250,250,250,1) 8%,rgba(158,31,99,1) 30%,rgba(158,31,99,1) 100%);/*Make the petal color*/
}
.leaf:nth-child(2) {
  animation: show-2 6s ease-in-out infinite;
}
.leaf:nth-child(3) {
  animation: show-3 6s ease-in-out infinite;
}
.leaf:nth-child(4) {
  animation: show-4 6s ease-in-out infinite;
}
.leaf:nth-child(5) {
  animation: show-5 6s ease-in-out infinite;
}
.leaf:nth-child(6) {
  animation: show-6 6s ease-in-out infinite;
}
.leaf:nth-child(7) {
  animation: show-7 6s ease-in-out infinite;
}
.leaf:nth-child(8) {
  animation: show-8 6s ease-in-out infinite;
}
.leaf:nth-child(9) {
  animation: show-9 6s ease-in-out infinite;
}

The above is the details of how to achieve the animation effect of lotus blooming with CSS3. For more information about CSS3 lotus blooming animation, please pay attention to other related articles on 123WORDPRESS.COM!

<<:  Manual and scheduled backup steps for MySQL database

>>:  Some front-end basics (html, css) encountered in practice

Recommend

Share some uncommon but useful JS techniques

Preface Programming languages ​​usually contain v...

Steps to set up Windows Server 2016 AD server (picture and text)

Introduction: AD is the abbreviation of Active Di...

CentOS 7 cannot access the Internet after modifying the network card

Ping www.baidu.com unknown domain name Modify the...

MySQL 8.0 user and role management principles and usage details

This article describes MySQL 8.0 user and role ma...

Analysis of the principle and usage of MySQL custom functions

This article uses examples to illustrate the prin...

Specific use of Bootstrap5 breakpoints and containers

Table of contents 1. Bootstrap5 breakpoints 1.1 M...

Detailed explanation of mandatory and implicit conversion of types in JavaScript

Table of contents 1. Implicit conversion Conversi...

Using CSS3 and JavaScript to develop web color picker example code

The web color picker function in this example use...

5 cool and practical HTML tags and attributes introduction

In fact, this is also a clickbait title, and it c...

Code to display the contents of a txt book on a web page

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML ...

Detailed introduction to the MySQL installation tutorial under Windows

Table of contents 1. Some concepts you need to un...

jQuery achieves seamless scrolling of tables

This article example shares the specific code of ...

A complete list of meta tag settings for mobile devices

Preface When I was studying the front end before,...

MySQL 5.7.23 installation and configuration method graphic tutorial

This article records the installation tutorial of...