Implement a eclipse animation using pure CSS3

Source: Internet
Author: User

Implement a eclipse animation using pure CSS3

The eclipse phenomenon is that the Moon blocks between the Earth and the Sun, that is, the Moon blocks the sun.

Therefore, to construct an eclipse, we need two objects: one representing the Moon and the other representing the sun.

We break down the entire eclipse process into three phases: 1. Slowly moving into 2. temporarily staying 3. Slowly moving out.

During this period, three associated animations are generated.

First, the position of the moon is moved. We can change the X coordinate of the Moon (left or right attribute value) (note that the sun and the moon are set to absolute positioning ).

Next, the sun will gradually show a halo of light, which we will use box-shadow to implement.

Box-shadow: 0px 0px 10px 5px # FFAD00;
At last, it is synchronized that the background of the entire page should be dimmed. This is relatively simple, just change the background-color of the body.
The rest is to compile the CSS rules of the key frames (keyframes) for the above stages.

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.