How to use CSS to realize the effect of single element lattice loader

Source: Internet
Author: User
This article mainly describes how to use CSS to achieve single-element lattice loader effect, has a certain reference value, and now share to everyone, the need for friends can refer to

Source code Download

The full source code of the daily Front end Combat series is available from GitHub:

Https://github.com/comehope/front-end-daily-challenges

Code interpretation

To define the DOM, there are only 1 elements:

<p class= "Loader" ></p>

Center display:

body {    margin:0;    HEIGHT:100VH;    Display:flex;    Align-items:center;    Justify-content:center;    Background:radial-gradient (Darkgreen 30%, forestgreen);}

Define Container Dimensions:

. loader {    width:10em;    Height:10em;    font-size:20px;}

2 groups of dots are drawn with Box-shadow:

. loader::before,.loader::after {    content: ';    Position:absolute;    Width:1em;    Height:1em;    Background-color:currentcolor;    Box-shadow:        0 0, 2em 0, 4em 0, 6em 0,        0 2em, 2em 2em, 4em 2em, 6em 2em,        0 4em, 2em 4em, 4em 4em, 6em        4em, 0 6em, 2em 6em, 4em 6em, 6em 6em;    border-radius:50%;}. Loader::before {    color:gold;}. loader::after {    color:dodgerblue;}

Defining animations:

@keyframes Round {    0% {        transform:translatex (0) translatey (0);    }    25% {        Transform:translatex (3em) translatey (0);    }    50% {        Transform:translatex (3em) Translatey (3em);    }    75% {        Transform:translatex (0) Translatey (3em);    }}

Finally, apply the animation effect to the dot matrix:

. loader::before,.loader::after {    animation:round 2s ease infinite;}. Loader::after {    animation-delay: -1s;}

Done!

The above is the whole content of this article, I hope that everyone's learning has helped, more relevant content please pay attention to topic.alibabacloud.com!

Related Article

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.