Using pure CSS3 to achieve an eclipse animation

Source: Internet
Author: User

The eclipse phenomenon is that the moon blocks between the Earth and the Sun, which is where the moon obscures the sun.

So to construct a solar eclipse, we need 2 objects: one for the moon and one for the sun.

<div class= "Eclipse Sun" ></div><div class= "Eclipse Moon" ></div>

We break the whole eclipse process into 3 stages: 1. Slowly move in 2. A short stay of 3. Slowly move out.

During this time, 3 animations associated with each other are generated.

First, the position of the moon moves, and we do this by changing the x-coordinate of the moon (left or right property values) (Note that the sun and the moon are set to absolute positioning).

Next the sun will gradually show the halo effect, we use the Box Shadow (Box-shadow) to achieve.

box-shadow:0px 0px 10px 5px #FFAD00;
Finally with this synchronization is, the entire page background to render a darkened effect, this is relatively simple, change the body of the background-color can be.
The rest is the CSS rules for writing key frames (keyframes) for the above phase.

You can try it yourself.



by Iefreer

Using pure CSS3 to achieve an eclipse animation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.