Dynamic motion for the circular progress bar during initialization

Seeking assistance to animate the round progress bar border upon page load. Looking for animations for various percentage values. Any suggestions are greatly appreciated! Thank you in advance!

For a similar animation example, click here.

.progress-circle {
   font-size: 20px;
   margin: 20px;
   position: relative; /* so that children can be absolutely positioned */
   padding: 0;
   width: 5em;
   height: 5em;
   background-color: #F2E9E1; 
   border-radius: 50%;
   line-height: 5em;
}

.progress-circle:after{
    border: none;
    position: absolute;
    top: 0.35em;
    left: 0.35em;
    text-align: center;
    display: block;
    border-radius: 50%;
    width: 4.3em;
    height: 4.3em;
    background-color: white;
    content: " ";
}
/* Text inside the control */
.progress-circle span {
    position: absolute;
    line-height: 5em;
    width: 5em;
    text-align: center;
    display: block;
    color: #53777A;
    z-index: 2;
}
.left-half-clipper { 
   /* a round circle */
   border-radius: 50%;
   width: 5em;
   height: 5em;
   position: absolute; /* needed for clipping */
   clip: rect(0, 5em, 5em, 2.5em); /* clips the whole left half*/ 
}
/* when p>50, don't clip left half*/
.progress-circle.over50 .left-half-clipper {
   clip: rect(auto,auto,auto,auto);
}
.value-bar {
   /*This is an overlayed square, that is made round with the border radius,
   then it is cut to display only the left half, then rotated clockwise
   to escape the outer clipping path.*/ 
   position: absolute; /*needed for clipping*/
   clip: rect(0, 2.5em, 5em, 0);
   width: 5em;
   height: 5em;
   border-radius: 50%;
   border: 0.45em solid #53777A; /*The border is 0.35 but making it larger removes visual artifacts */
   /*background-color: #4D642D;*/ /* for debug */
   box-sizing: border-box;

}
/* Progress bar filling the whole right half for values above 50% */
.progress-circle.over50 .first50-bar {
   /*Progress bar for the first 50%, filling the whole right half*/
   position: absolute; /*needed for clipping*/
   clip: rect(0, 5em, 5em, 2.5em);
   background-color: #53777A;
   border-radius: 50%;
   width: 5em;
   height: 5em;
}
.progress-circle:not(.over50) .first50-bar{ display: none; }


/* Progress bar rotation position */
.progress-circle.p0 .value-bar { display: none; }
.progress-circle.p1 .value-bar { transform: rotate(4deg); }
.progress-circle.p2 .value-bar { transform: rotate(7deg); }
.progress-circle.p3 .value-bar { transform: rotate(11deg); }
.progress-circle.p4 .value-bar { transform: rotate(14deg); }
.progress-circle.p5 .value-bar { transform: rotate(18deg); }
.progress-circle.p6 .value-bar { transform: rotate(22deg); }
.progress-circle.p7 .value-bar { transform: rotate(25deg); }
.progress-circle.p8 .value-bar { transform: rotate(29deg); }
.progress-circle.p9 .value-bar { transform: rotate(32deg); }
.progress-circle.p10 .value-bar { transform: rotate(36deg); }
.progress-circle.p11 .value-bar { transform: rotate(40deg); }
.progress-circle.p12 .value-bar { transform: rotate(43deg); }
.progress-circle.p13 .value-bar { transform: rotate(47deg); }
.progress-circle.p14 .value-bar { transform: rotate(50deg); }
.progress-circle.p15 .value-bar { transform: rotate(54deg); }
.progress-circle.p16 .value-bar { transform: rotate(58deg); }
.progress-circle.p17 .value-bar { transform: rotate(61deg); }
.progress-circle.p18 .value-bar { transform: rotate(65deg); }
.progress-circle.p19 .value-bar { transform: rotate(68deg); }
.progress-circle.p20 .value-bar { transform: rotate(72deg); }
.progress-circle.p21 .value-bar { transform: rotate(76deg); }

Answer №1

By hiding the black percentage circle, you can observe that the use of CSS to generate two half-circles with borders is employed and then rotated based on the percentage value:

https://i.sstatic.net/892Z0.png

Below is their code snippet for creating the half circle border:

.progress-bar {
    animation: loading-2 1.5s linear forwards 1.8s;
    border-color: #049dff;
    border-top-right-radius: 80px;
    border-bottom-right-radius: 80px;
    border-left: 0;
    transform-origin: center left;
}

It's important to note their utilization of animation-fill-mode: forwards in order to ensure the animation stays at its final state.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

AJAX fails to retrieve a result

I've been attempting to grasp the concept of using ajax, but unfortunately I have not been able to receive any response. Here is the HTML code: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta ...

Place two anchors side by side using inline-blocks without using the float property

Is there a way to align two buttons next to each other without using floating? I have encountered an issue where adding a width to one of the buttons causes it to jump down and be on a different line than the other button. The buttons are centered, so th ...

What is the best way to tally up words contained within an HTML element using Javascript?

When I type or paste words into a textarea, the total number of words will be displayed at the top. I have managed to count the words when using the element <textarea id="text"></text>. However, I am unable to count the total number of words ...

Conceal a bootstrapTable column with the power of JavaScript or jQuery

I have incorporated bootStrap Table in order to display information for my users based on the following example. In my table, I am attempting to hide the Edit and Delete options by concealing the operate (Delete User Column) data field. I attempted using ...

Removing an item from a list by clicking a button

I am currently developing my own version of a mini Twitter platform. Everything is functioning smoothly, however I am facing an issue with deleting specific tweets upon the click of a button. I have attempted using splice(), but it consistently deletes th ...

Choose a specific item by its name and retrieve its corresponding identifier using Angular

In my current MVC project using HTML and angular, I am facing an issue with a select list. The list is supposed to be selected based on the name entered in an input box, but unfortunately, I am unable to retrieve the id associated with the selected item. ...

Creating a custom HTML5 pattern for formatting Pakistani phone numbers

For my HTML5 pattern for Pakistan Phone Number Format, I have the following criteria: 03xx-xxxxxxx My current regex code is as follows: /03[0-9]{2}-[0-9]{7}/ Now, I want to ensure that the next 7 digits after the hyphen meet the following conditions: ...

Review and add alt attributes to images that are missing them

I have a plan to create a Java tool that can evaluate HTML pages on an existing website. The goal is to add the alt="" attribute to any image that currently lacks it. One idea is to use an HTML parser, such as HtmlCleaner, to generate a DOM structure of th ...

If the checkbox is selected, retrieve the product name and price and store them in an array

If the checkbox is checked, I want to retrieve the service name and its price in an array. To get the values of the selected items (i.e. service name and its price in an array), please explain how I can achieve this. $(document).on('click', &apos ...

What is the best way to continuously run a series of functions in a loop to create a vertical news ticker effect?

I'm in the process of creating a vertical latest news ticker, and although I'm new to javascript, I'm eager to learn and build it myself. So far, I've come up with this, but I want the news cycle to restart once it reaches the end. ...

Creating an animated sidebar that moves at a different speed than the rest of the

I have a layout with a large sidebar and small content, where the "Fixed part" refers to sticky positioning. I'm attempting to achieve this using scrollTop, but the sidebar is causing some issues like this: The code should only be executed when the ...

Incorporate personalized fonts onto your website

After downloading the Arimo font from Google Fonts, I decided to create a master page and a stylesheet for it. Here is the code I wrote: @font-face{ font-family:"Arimo"; src: url('../Fonts/Arimo/Arimo-Regular.ttf'),format('truetype& ...

Tips for verifying the presence of a 3D model from Spline API within the DOM using Next.js

I am in the process of developing a brand new website and I have integrated a 3D model from spline, although it is taking quite some time to load. To improve user experience, I decided to implement a loader/Spinner. However, I'm facing the challenge o ...

Issue with transition not being activated after the implementation of display: table

I am facing an issue with a <table> nested within a <div>. My goal is to make the <div> scale according to the size of the <table>, but this transition seems to fail when I apply display: table; in my CSS. The <div> should onl ...

jQuery Mobile and PhoneGap Contact Form

I've been trying to find a solution on my own, but so far I haven't had any luck. I'm looking for a contact form that I can integrate into my jQuery Mobile and PhoneGap application. My server runs on node.js. Does anyone have a working exam ...

Ways to implement a CSS transition effect on a sidebar menu?

I successfully implemented a sidebar menu and now I am looking to enhance its appearance by adding transitions for a more polished look. Below is a snippet of my current code: $('.menu-toggle').on('click', function() { $('bo ...

JavaScript layout: Thymealf

I have a unique thymeleaf template like so: <body> <div id="layout"> <!-- Menu toggle --> <a href="#menu" id="menuLink" class="menu-link"> <!-- Hamburger icon --> <span>& ...

The MaterialUI TextField isn't behaving as expected when attempting to change the background color

Currently, I am facing a challenge with setting the background color for my `TextField` components within the app I am developing. Despite adding custom RGB values using `style={{background: "rgb(232, 241, 250)"}}`, the component continues to dis ...

SQL Server database is showing question marks instead of HTML symbols

Recently, I observed that special HTML symbols like: ★ are appearing as question marks in my database records. I have set the type of the field as varchar and am utilizing Microsoft SQL 2008 for my database management. Is there a solution to this symbo ...

Having difficulty implementing a hover event on a sibling element of a target using either the duration parameter in jQuery UI or CSS

My objective is to alter the background color of an element and one of its higher siblings in the DOM but within the same parent upon hover. While I successfully used CSS transition to change the first element, I encountered difficulty getting the sibling ...