Css circle fill animation

Circular Progress Bar using HTML and CSS

Circular Progress Bar is a popular web element that is mainly used on business or personal websites. If you want to create a circular progress bar using HTML and CSS, then this article will help you. Here I am going to show you how to make a simple CSS circle progress bar. When you load the page, this animation will go from zero to your assigned meaning. A percentage of text is used here, but no animation is used in this text. It is made in a very simple way. ✅ Watch Live Preview 👉👉 Circular Progress Bar In this article, I will show you step by step how I made this circular progress bar design.To make it, you need to have an idea about basic HTML and CSS.

Step 1: The basic structure of Circular Progress Bar

I have used HTML and CSS to create the basic structure of the Circular Progress Bar. I have created a small circle on the webpage. The width and height of this circle are 150 px. The background color of the circle is white and margins are used to place it in the middle.

 class="circle-wrap">  class="circle">   
body  font-family: "Roboto", sans-serif; background:#d2eaf1; > .circle-wrap  margin: 150px auto; width: 150px; height: 150px; background: #fefcff; border-radius: 50%; border: 1px solid #cdcbd0; > 

The basic structure of Circular Progress Bar

Step 2: Half of the simple CSS circle progress bar

As I said before, the animation in this circle is divided into two parts. This means that the animation has been divided into two parts up to the customer value. I have made the first part of those two parts. Width and height 150 have been used to make this animation equal in size to the Circular Progress Bar. Similarly, border-radius 50% has been used to make it round. Here I have set the background-color to blue. If you want to play an animation in another color, you can use that color here.

 class="mask half">  class="fill">
.circle-wrap .circle .mask, .circle-wrap .circle .fill  width: 150px; height: 150px; position: absolute; border-radius: 50%; > .mask .fill  clip: rect(0px, 75px, 150px, 0px); background-color: #227ded; > 

Half of the simple CSS circle progress bar

Step 3: The other half of the Circular Progress Bar

Now I have designed the other half of the Circular Progress Bar. I set the time to three seconds by adding animation here. This means that when this page is opened, the animation will take 3 seconds to reach the meaning you set from zero. Here 135 degrees have been used using transform. This transform will determine where the animation will end in this circle. ➤ We know that a circle is formed by 360. Since here we have divided the CSS circle progress bar into two parts, so each part is 180 degrees. ➤ Here we have set a 135-degree animation for each part using Transform. So it will be 270 degrees for the total circle. Here I want to increase the animation to 75% so I have used 270 degrees.

You determine the value of this degree according to your needs. For example, if you want the animation of the Circular Progress Bar will be up to 80%. But for that, you have to use 144 degrees here . Lastly, I have implemented this animation using @keyframes.

 class="mask full">  class="fill">
.circle-wrap .circle .mask  clip: rect(0px, 150px, 150px, 75px); > .mask.full, .circle .fill  animation: fill ease-in-out 3s; transform: rotate(135deg); > @keyframes fill 0%  transform: rotate(0deg); > 100%  transform: rotate(135deg); > > 

The other half of the Circular Progress Bar

Step 4: Create a percentage in the Circular Progress Bar

Now I have added percentages in this circular progress bar. Although that percentage of animation is not added. Added text using basic HTML and CSS code. I have used text-align: center and position: absolute to place the text in the middle of the Circular Progress Bar. I used border-radius: 50% to make its background width and height 122 px and round. Here I have used font-size: 2em to make the size of the text smaller and larger.

.circle-wrap .inside-circle  width: 122px; height: 122px; border-radius: 50%; background: #d2eaf1; line-height: 120px; text-align: center; margin-top: 14px; margin-left: 14px; color: #1e51dc; position: absolute; z-index: 100; font-weight: 700; font-size: 2em; > 

Circular Progress Bar using HTML and CSS

Related Post:

  1. Responsive Footer HTML CSS
  2. Todo List using JavaScript
  3. Simple Stopwatch using JavaScript
  4. Javascript Age Calculator
  5. javaScript Password Generator
  6. Automatic Image Slider in Html CSS
  7. Sidebar Menu Using HTML CSS

As you can see in the picture above, now this CSS Circular Progress Bar is absolutely ready. Hope you find out from this article how I created this Circular Progress Bar using HTML and CSS.

Источник

CSS Circle Border Fill Animation

There is a very easy to follow, informative and detailed tutorial on exactly how to achieve this (and more) by Anders Ingemann, which can be found here.

Its a fairly complex operation- so I’ll simply distil the final stage from the tutorial here

Demo Fiddle

.radial-progress @circle-size: 120px; 
@circle-background: #d6dadc;
@circle-color: #97a71d;
@inset-size: 90px;
@inset-color: #fbfbfb;
@transition-length: 1s;
@shadow: 6px 6px 10px rgba(0, 0, 0, 0.2);
margin: 50px;
width: @circle-size;
height: @circle-size;
background-color: @circle-background;
border-radius: 50%;
.circle .mask, .fill, .shadow width: @circle-size;
height: @circle-size;
position: absolute;
border-radius: 50%;
>
.shadow box-shadow: @shadow inset;
>
.mask, .fill -webkit-backface-visibility: hidden;
transition: -webkit-transform @transition-length;
transition: -ms-transform @transition-length;
transition: transform @transition-length;
>
.mask clip: rect(0px, @circle-size, @circle-size, @circle-size/2);
.fill clip: rect(0px, @circle-size/2, @circle-size, 0px);
background-color: @circle-color;
>
>
>
.inset width: @inset-size;
height: @inset-size;
position: absolute;
margin-left: (@circle-size - @inset-size)/2;
margin-top: (@circle-size - @inset-size)/2;
background-color: @inset-color;
border-radius: 50%;
box-shadow: @shadow;
>
>

Example jQuery (could be substituted with CSS)

$('head style[type="text/css"]').attr('type', 'text/less');
less.refreshStyles();
var transform_styles = ['-webkit-transform', '-ms-transform', 'transform'];
window.randomize = function () var rotation = Math.floor(Math.random() * 180);
var fill_rotation = rotation;
var fix_rotation = rotation * 2;
for (i in transform_styles) $('.circle .fill, .circle .mask.full').css(transform_styles[i], 'rotate(' + fill_rotation + 'deg)');
$('.circle .fill.fix').css(transform_styles[i], 'rotate(' + fix_rotation + 'deg)');
>
>
setTimeout(window.randomize, 200);
$('.radial-progress').click(window.randomize);

Animating a circle border to fill up

There is a lot ways to do it, here are some

  • http://fromanegg.com/post/41302147556/100-pure-css-radial-progress-bar
  • http://www.alessioatzeni.com/blog/css3-loading-animation-loop/

Filling a circle border by percent

For first linear part, you can use linear-gradient:(270deg. ) for filling 50% of the circle.

For other linear part, you can increase the angle (270°+) to fill more than 50% of the circle (360° or 0° = 75% of the circle . 90° = 100% of the circle)

For example: linear-gradient(270deg, black 50%, transparent 50%), linear-gradient(0deg, black 50%, lightgray 50%) combination creates a circle with a lightgray background, filled with seventy-five percent black color. (snippet below)

Circle to fill a container animation

You may use box-shadow instead transform and a pseudo a bit smaller to avoid the buggy gap around the container and the shadow;

body <>
#circle < width: 45px; height: 45px; border-radius: 50%; position: absolute; z-index: 999999999; top: 30px; left: 30px; background-color: black;>
#circle::before < content: ''; height: 28px; width: 28px; position: absolute; top: 3px; left: 3px; border-radius: inherit; transition: 0.75s ease; box-shadow: 0 0 0 0vw;>
#circle.clicked::before

Hover effect in circle border

If I understand you correctly, here is one way you could make this work.

There are 3 elements to this; the image, the circle and the gap.

  • The circle is a div with a border-radius to round it out, and a border with the color of your choice.
  • The gap is a div that is the full height of the wrapper and the width of the intended gap. The div is given the same color as the background (white in this case — change to whatever you want). Then we apply a transform of -30deg to get the angle in your example.
  • The image is a div with a border-radius and is positioned in the middle of the wrapper.

The css then makes use of keyframes to add an animation to the gap div to make it rotate when you hover over the wrapper. This gives the illusion of the circle rotating.

.wrapper position: relative; 
height: 350px;
width: 350px;
>

.wrapper .circle position: absolute;
height: 340px;
width: 340px;
border: 5px solid #00C17F;
border-radius: 50%;
>

.wrapper .gap position: absolute;
width: 100px;
height: 350px;
left: 125px;
background: white;
-ms-transform: rotate(-30deg);
-moz-transform: rotate(-30deg);
-webkit-transform: rotate(-30deg);
-o-transform: rotate(-30deg);
transform: rotate(-30deg);
>

.wrapper:hover .gap display: block;
-webkit-animation: rotateCircle 20s linear infinite;
-moz-animation: rotateCircle 20s linear infinite;
-ms-animation: rotateCircle 20s linear infinite;
-o-animation: rotateCircle 20s linear infinite;
animation: rotateCircle 20s linear infinite;
>

.wrapper .image position: absolute;
background-image: url("https://upload.wikimedia.org/wikipedia/commons/f/f2/Light_Work_%28Unsplash%29.jpg");
background-size: cover;
background-position: right;
border-radius: 50%;
top: 10%;
left: 10%;
height: 80%;
width: 80%;
>

@keyframes rotateCircle from -ms-transform: rotate(-30deg);
-moz-transform: rotate(-30deg);
-webkit-transform: rotate(-30deg);
-o-transform: rotate(-30deg);
transform: rotate(-30deg);
>

to -ms-transform: rotate(330deg);
-moz-transform: rotate(330deg);
-webkit-transform: rotate(330deg);
-o-transform: rotate(330deg);
transform: rotate(330deg);
>
>

Percentage circle border CSS React

Is don’t think it’s particularly a bug in your code — it’s just that the system is trying to work out how to show part CSS pixels on a screen which uses several screen pixels per CSS pixel. Some can get ‘left behind’.

A different way of creating the effect you want is to use background images made up of a conic gradient overlaid with a radial one (to give the ‘hole’ in the middle).

This is a simple snippet to demonstrate the idea in HTML/CSS. The CSS variable —ratio could be set in JS using setProperty to whatever the ratio of red to green is required.

.ratio --ratio: 0.3; 
height: 150px;
width: 150px;
border-radius: 50%;
position: relative;
clip-path: circle(50%);
>

.ratio::before content: '';
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
background-image: conic-gradient(red 0 calc(var(--ratio) * 360deg), lime calc(var(--ratio) * 360deg) 360deg);
z-index: -2;
>

.ratio::after content: '';
position: absolute;
width: 80%;
height: 80%;
top: 10%;
left: 10%;
background-color: white;
border-radius: 50%;
z-index: -1;
>

Specific way to animate Circle Border with SVG?

That is, the gray lines should keep disappearing as they are now,
with the top disappearing at the same rate as the bottom. How do I do
this?

To do this, you must change the parameters of the stroke-dasharray attribute.

With a radius of a circle r = 49 , the total circumference is 308

To make a symmetrical disappearance of a stroke with two lines from one point, you need to use two groups of parameters stroke-dasharray

values=»154, 0 154, 0; 0, 308, 0, 0″ where

154 — dash parameter of the first group stroke-dasharray

0 — gap parameter of the first group stroke-dasharray

As a result, the circle will be filled with a cavity at the first moment of the animation.

0, 308, 0, 0 — at this value, the length of the gap is maximum and the border of the circle becomes invisible

 
stroke-width="6" stroke="#838588" fill="none">

Источник

Читайте также:  Php коды символов таблиц
Оцените статью