CSS3 Animation for Enrollment Progress Bar

https://i.sstatic.net/aYwHP.png

How can I best incorporate this functionality?

<div class="container">
  <h2>Simple Progress Bar</h2>
  <div class="progress">
    <div class="progress-bar" role="progressbar" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" style="width:50%">
      <span class="sr-only">70% Complete</span>
    </div>
  </div>
</div>

Should I include numbers on the progress bar as text, or should I use CSS3 to create a circular design? If so, can someone provide an example?

Answer №1

Check out this live demonstration showcasing how to create a visually appealing design using CSS. While this example is quick and rudimentary, I suggest streamlining the CSS and potentially utilizing JavaScript and CSS pseudoelements to generate the HTML for a more production-ready approach. Additionally, consider incorporating CSS animations to add dynamic color effects. The purpose of this demo is to provide inspiration and ignite creativity.

View the final screenshot:

https://i.sstatic.net/j2xBn.png

Live Demo:

html, body {
    background-color: #555048;
}

.segment {
    position: relative;
    display: inline-block;
    margin-right: -10px;
}
.circle {
    display: inline-block;
    background-color: #A8A9AD;
    width: 20px;
    height: 20px;
    line-height: 20px;
    border-radius: 50%;
    color: white;
    overflow: hidden;
    text-align: center;
    font-size: 12px;
}
.line {
    display: inline-block;
    width: 80px;
    height: 10px;
    margin: 5px 0;
    background-color: #A8A9AD;
    position: relative;
    left: -5px;
}
.label {
    position: absolute;
    left: 10px;
    top: 35px;
    transform: translate(-50%, 0);
    font-size: 12px;
    color: #A8A9AD;
}
.container {
    margin: 50px;
}
.segment.active .circle, .segment.active .line {
    background-color: #C0A05F;
}
.segment.active .label {
    color: #C0A05F;
}
<div class="container">
<div class="segment active"><div class="circle">1</div><div class="label">PERSONAL</div><div class="line"></div></div>
<div class="segment active"><div class="circle">2</div><div class="label">PROFILE</div><div class="line"></div></div>
<div class="segment"><div class="circle">3</div><div class="label">EXPERIENCE</div><div class="line"></div></div>
<div class="segment"><div class="circle">4</div><div class="label">SETTING</div><div class="line"></div></div>
<div class="segment"><div class="circle">5</div><div class="label">CERTIFICATE</div><div class="line"></div></div>
<div class="segment"><div class="circle">6</div><div class="label">SUBMIT</div></div>
</div>

JSFiddle Version: https://jsfiddle.net/8hxqunLx/1/

Answer №2

Let's design something elegant and appealing!

Here is the final outcome:

https://i.sstatic.net/MPlBS.png

The HTML Structure

Utilize an ordered list to structure your content effectively:

<ol>
    <li class="complete">Personal</li>
    <li class="complete">Profile</li>
    <li>Experience</li>
    <li>Setting</li>
    <li>Certificate</li>
    <li>Submit</li>
</ol>

To mark a step as complete, simply add the complete class to change its background color.

The CSS Styling

The Counting Numbers

For an in-depth guide on using the counter property, check out Smashing Magazine.

The numbers are generated using a counter and displayed within the list items through CSS:

ol {
  list-style: none;
  counter-reset: counter;
}

ol li {
  counter-increment: counter;
}        

ol li::before {
  content: counter(counter, decimal);
}

The numbers are positioned above the text using position: absolute.

The Progress Bar

Learn more about pseudo-elements from the MDN documentation.

Here's how the progress bar looks behind the numbers:

https://i.sstatic.net/r1Qwp.png

It's created using a ::before pseudo-element with a gradient background. Adjust the percentage values to reflect completion status:

ol::before {
  content: '';
  height: 8px;
  background: 
    linear-gradient(to right, #BFA15F 0, #BFA15F 40%, #A8A9AD 40%, #A8A9AD 100%);
  position: absolute;
  left: 50px;
  right: 50px;
  top: 6px;
}

Customizing the Numbers

The numbers can be further styled using the ol li::before selector:

  • border-radius: 50% creates a circular shape
  • text-align: center and line-height: 20px center the number within the circle
  • Change the background color based on completion status

Complete Demo

Note: Avoid whitespace between list items to eliminate gaps. Check out this article for more details.

Here is a complete example with HTML and CSS snippets:

Visual Animation

To animate the progress bar, consider using two pseudo-elements with a sliding effect:

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  font-family: arial;
}
ol {
  list-style: none;
  counter-reset: counter;
  position: relative;
  width: 600px;
  margin: 50px auto;
  white-space: nowrap;
}
ol::before {
  content: '';
  position: absolute;
  height: 8px;
  background: linear-gradient(to right, #BFA15F 0, #BFA15F 40%, #A8A9AD 40%, #A8A9AD 100%);
  left: 50px;
  right: 50px;
  top: 6px;
}
ol::after {
  content: '';
  position: absolute;
  height: 8px;
  background: #BFA15F;
  left: 50px;
  top: 6px;
  animation: stretch 2s linear infinite;
}
ol li {
  counter-increment: counter;
  display: inline-block;
  position: relative;
  text-transform: uppercase;
  font-size: 0.7em;
  padding-top: 30px;
  width: 100px;
  text-align: center;
}
ol li::before {
  content: counter(counter, decimal);
  position: absolute;
  background: #A8A9AD;
  top: 0;
  left: 50%;
  margin-left: -10px;
  width: 20px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  border-radius: 50%;
  color: #FFF;
  font-weight: bold;
  z-index: 1;
}
ol li.complete::before {
  background: #BFA15F;
}
@keyframes stretch {
  0% {
    width: 0;
  }
  100% {
    width: calc(100% - 100px);
  }
}
<ol>
  <li class="complete">Personal</li><li class="complete">Profile</li><li>Experience</li><li>Setting</li><li>Certificate</li><li>Submit</li>
</ol>

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

Converting CSS properties to MaterialUI Styles in ReactJS: A step-by-step guide

In my CSS, I've included the following code: [contentEditable=true]:empty:not(:focus):before{ content:attr(data-text) } This snippet allows me to display a placeholder inside a content-editable div when it is empty. Since I am using Material-UI ...

Map / Area enveloped in darkness

I'm currently working on a map that includes an area, but I'd like to add a shadow effect around it. I'm struggling to figure out how to achieve this. <map name="map_bottom"> <area id="area_bottom" shape="poly" coords="0,0,0,37 ...

Positioning the dropdown menu on the right with Boostrap 5.2 Navbar

After grappling with this problem for the past 72 hours, I've exhausted all my options and still can't seem to resolve it. I am currently working with Bootstrap 5.2 and have implemented a Navbar with a dropdown menu. My objective is to position i ...

Tips for transferring data from a controller to $scope in the MVC architecture with AngularJS

I'm a beginner when it comes to AngularJS, currently working with an MVC5 application. I have set up a module and controller in the Angular JS for this application. Within my customer controller in MVC5, I have an action called "View" where I need to ...

The icons in webviews on mobile apps (iOS and Android) fail to render correctly

My font icons are behaving inconsistently on webkit-based mobile browsers when used on mobile devices. When hovering over the span on a desktop browser, the icon properly fills its container: https://i.sstatic.net/qzrmz.png However, when hovering over t ...

Guide on adjusting image dimensions in JTextPane using HTML and CSS in the Java Swing environment

I am looking to add an image (such as a formula created from LaTeX) into JTextPane, using HTML+CSS for text formatting and manually setting its size. I attempted the following approach: import java.awt.Dimension; import javax.swing.JFrame; import javax.swi ...

Text is not visible when hovering over it

I am facing an issue with the hover effect on my menu element. When I hover over the element, the text does not appear as expected. Even after using z-index to position the text on top, it still doesn't work. Here is a snippet of my code: HTML: < ...

Limiting the character input in ion-textarea within Ionic 2: A step-by-step guide

In my Ionic 2 application, I need to limit user comments to less than 500 characters in a text area. What is the best way to implement this restriction? ...

Is client-side rendering the new trend, bypassing traditional server-side rendering?

I'm exploring the idea of rendering my pages on the client side to reduce server load and minimize traffic. Typically, the first request to the server requires it to render the requested page and then send it to the user. Once the user interacts with ...

What is the significance of utilizing response.json() for accessing JSON objects on both the server and client sides?

Just starting out with the MEAN stack, I've included my API code below where I'm using res.json(random) to send a random password. module.exports.changePass = function (req, res) { console.log(req.body.email) db.user.find({ where: { name: ...

Unable to render the ng-repeat child scope attribute

I am working on displaying a list of data records using ng-repeat. Each data object entry (referred to as a coupon) needs to have specific properties ($scope.etabName and $scope.etabDistance) extracted from it, calculations performed, and the results displ ...

Switching from a click event to a hover event in JavaScript

I've been experimenting with animating a burger bar on hover and came across an example online that I managed to adapt for mouseenter functionality. However, I'm struggling to make it revert back to the burger bar shape once the mouse leaves on m ...

Altering the look of a button as you navigate to it by tabbing

Check out this code snippet: In my design, I have set it up so that the user can tab through the username field first, then the password field, followed by the login button and finally the navigation tabs labeled "Getting Started" and "Vegetables." The i ...

The navigation bar on the web app is functioning properly on Android devices but experiencing a CSS problem on

My Nextjs web app includes a navbar with a hamburger menu, logo, and avatar. The navbar functions perfectly on desktop in Chrome, Mozilla, Brave (in developer tools mobile mode), and on Android phones using Chrome. However, when accessed from an iPhone X, ...

Do not engage with the website while animations are running

I'm working on a JavaScript project where I want to create textareas that grow and center in the window when clicked, and shrink back down when not focused. However, I ran into some issues with the .animate() function that are causing bugs. During QA ...

Obtain the real-time inventory quantity of the specific product variation in WooCommerce

When a WooCommerce product variation's stock quantity is 0 or less and backorders are allowed, I want to offer customers the option to pre-order the item on the product page. To clearly indicate this to customers, the "Add to Cart" button should chan ...

Problem with AngularJS date range picker: inability to use next and previous buttons on mobile devices

I am currently using the Angular date range picker within my Ionic application. The issue that I am currently encountering is that the 'next' and 'previous' buttons do not seem to be working when viewing the app on a mobile device or in ...

The Jquery function for selecting a div added by an Ajax call is not functioning properly, but it works fine without the need for an

I have a unique checkbox that I created using an Ajax call. The issue I'm facing is that the jQuery to select the checked input in the second div #test_checkbox_ajax isn't working, while it works perfectly fine in the first div #test_checkbox. Cr ...

Place a div image on top of a form div

Currently, I have a simple form set up with the following HTML code: <div class="card mb-5 card-central-responsive" style="min-height: 579px;"> <div class="card-body"> <form #apkCreationForm="ngForm" class="mt-2" novalidate (ngSubmit ...

Using Gulp to Minify Modules in AngularJS

I need help setting up a structure to minify and uglify all of my angular code efficiently. After attempting to replicate the angular module structure from the Angle Bootstrap Theme, I encountered issues when trying to minify the files and ended up with m ...