Results show

Hello everyone, this is Yearth, welcome to 10 mins CSS, spend 10 minutes a day to achieve a simple and beautiful CSS effect.

So let’s get straight to the point. Let’s take a look at today’s results:

Picture 1

The key point

To analyze the key points of this effect:

  • Mask layer frosted glass effect
  • The bottom layer is a quarter of a round block, not a whole

The specific implementation

This effect is not complicated, let’s analyze the implementation of the above key points.

Frosted glass effect

In CSS, we use a backdrop – filter filter effects, specific can take a look at this article: backdrop – filter – | CSS Tricks.

Also, add a light background color to the mask layer:

.loader .cover {

  position: absolute;

  top10px;

  left10px;

  right10px;

  bottom10px;

  backgroundrgba(233.30.99.0.05);

  border-radius50%;

  backdrop-filterblur(10px);

  border1px solid rgba(255.255.255.0.1);

  z-index2;

}

Copy the code

The effect is as follows:

Picture 2

Color piece

In order to achieve the final quarter circle, there are quite a few options, but here are two simple ones.

  • clip-path
  • pseudo-classes

Let’s look at clip-path first. We know that, in theory, clip-Path can implement arbitrary graphics. Here is a recommended tool website: Clippy.

.loader .block {

  position: absolute;

  top50%;

  left50%;

  width100%;

  height100%;

  z-index1;

  backgroundvar(--loader-color);

  clip-pathcircle(50% at 0 0);

}

Copy the code

The effect is as follows:

Picture 3

Rotate the transform: rotate is simple. Rotate the transform: origin in the upper left corner of the color block.

.loader .block {

 / *... * /

  animation: rotate 1s linear infinite;

  transform-origin: top left;

}



@keyframes rotate {

  0% {

    transformrotate(0deg);

  }

  100% {

    transformrotate(360deg);

  }

}

Copy the code

The effect is as follows:

Picture 4

To achieve this effect with pseudo-classes, note the details: we can use blocks to implement the outline, and then use pseudo-classes to fill in the color, as follows:

.loader .block {

  position: absolute;

  top0;

  left0;

  width100%;

  height100%;

  border-radius50%;

  z-index1;

  overflow: hidden;

  animation: rotate 1s linear infinite;

}

.loader .block::before {

  content"";

  position: absolute;

  top: -50%;

  left: -50%;

  width100%;

  height100%;

  backgroundvar(--loader-color);

}

Copy the code

The effect is as follows:

Picture 5

It’s in the back

Today’s effect is relatively simple, interested readers can see the online demo: Ground-glass Loader effect