Creating a slick progress bar using a combination of HTML, CSS, and JavaScript

Looking to create a progress bar similar to the one shown in the image below?

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

Answer №1

To achieve this effect, a straightforward method would involve the following:

Styling with CSS:

.tracker
{
    position:relative;
    width: 100px;
    height: 100px;
}

.trackerBase
{
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: url('baseImage.jpg');
}

.trackerFill
{
    position: absolute;
    width: 100%;
    height: 0%;
    background-image: url('fillImage.jpg');
}

.trackerPercentage
{
    position:absolute;
    top: 40px;
    width: 100%;
    text-align: center;
}

Incorporating HTML elements:

<div class='tracker'>
  <div class='trackerBase'/>
  <div class='trackerFill' />
  <div class='trackerPercentage'>0%</div>
</div>

For dynamic animation, utilize JavaScript to modify the height of div.trackerFill representing progress and update the .trackerPercentage display accordingly.

Answer №2

To achieve the desired effect, consider incorporating an animation. Additionally, as suggested by The Molecule, utilizing height for the color may be necessary. It is important to understand how a standard circle function operates. Start by creating a circle and following The Molecule's guidance on setting the height. Next, ensure that the inside of the circle remains transparent or unnecessary. Once these steps are completed, the heights will be displayed within the circle. While I have not personally attempted this technique as I do not use custom loading bars.

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

The JAVASCRIPT function fails to interpret echoed HTML Element generated by PHP

My HTML elements are generated from PHP as most content is fetched from the database. For example: <?php ... while($row = $sqlQry->fetch_object()) { echo "<li class='lstOption' id='opt$row->name' data-value ...

Maximizing page space with ReactJS and advanced CSS techniques

I'm currently in the process of learning CSS and struggling a bit with it. My main issue right now is trying to make my react components fill the entire height of the browser window. I've been using Display: 'grid' and gridTemplateRows: ...

Tips for preventing page breaks (when printing or saving as a PDF) in lengthy HTML tables

Here is the link to a single HTML file (including style and scripts): FQ.html The problem I'm facing can be seen in this image: https://i.sstatic.net/Nr4BZ.png I've tried several solutions, the latest of which involves the following CSS... @me ...

Creating a Yup field that is an object and making it required when another field is set to true in the validation process

Just getting started with Yup validation and I'm facing an issue. I am attempting to make certain fields required based on a condition. Specifically, I want the digital object to be required only if hasDigital is true; otherwise, it should be optional ...

Show/Hide sections of content that transition and rearrange the layout of the page

I have a layout with 9 squares on a page. When clicking on a square, I want a full-width div to appear underneath it, pushing the other squares down. I've tried following a tutorial to understand the JavaScript behind this functionality, but I'm ...

jquery expanding the width of the final element

Is there a way to increase the width of the last 'th' in a string? I want it to be the current width plus 20px. Here is the code on Fiddle var header="<th id='tblHeader_1' style='width: 80px;'><span>Id</span&g ...

Calculating the total price of items in a shopping cart by multiplying them with the quantity in Vue.js

I am currently working on enhancing the cart system in Vue.js, with a focus on displaying the total sum of product prices calculated by multiplying the price with the quantity. In my previous experience working with PHP, I achieved this calculation using ...

making a Jquery call with a GET request

Check out this code snippet: $("#autocomplete").autocomplete({ source: ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"], close: function (event, ui) { alert($(this).val()); } }); <label for="autocomplete">Pick ...

"click on the delete button and then hit the addButton

I have created a website where users can save and delete work hours. I am facing an issue where I can save the hours at the beginning, but once I delete them, I cannot save anything anymore. Additionally, when I reload the page, the deleted data reappears. ...

Navbar transition issue in Bootstrap

Having trouble with Bootstrap transitions not functioning correctly on my navbar. The issue is when I click the dropdown button in the navbar, the hidden elements appear abruptly without any transition effect. Below is the HTML code being used: <!do ...

Having trouble with my Angular subscription - not behaving as I anticipated

I am facing an issue on my shop page where I have a FilterBarComponent as a child component. On initialization, I want it to emit all the categories so that all products are rendered by default. However, on my HomePageComponent, there is a button that allo ...

Exploring innovative designs for asynchronous JavaScript programming

Imagine you have an Express app and you need to retrieve data from a database to display on the frontend. There's a function in your code that looks like this (using node-mysql for handling database queries) exports.getData = function() { ...

Fixing multiple file upload error: Resolving Invalid argument for foreach() while using Ajax and Php

I am struggling with a problem related to retrieving all the files on the back end side (PHP). When I upload multiple images, only one image is shown on my var_dump. My goal is to upload multiple images to the database when the user uploads multiple items ...

Discrepancy in performance of jQuery.load function between local machine and remote server

When utilizing the jQuery.load function to create dynamic pages and sending data using the POST method, I encountered an issue. On my local PC (Windows with Apache/PHP server), everything worked perfectly. However, upon uploading it to my hosting server on ...

Tips for effectively utilizing the Angular ngIf directive for toggling the visibility of elements

<div *ngFor = "let element of myElements, let i=index" [ngClass]="{'selected':element[i] == i}"> <li> Name: {{element.element.name}}</li> <li> Description: {{element.element.description}}</li ...

Load as soon as the browser is launched

I have developed a unique button that utilizes JavaScript to display the server status through an API. However, I am facing an issue where the server status does not automatically load when the browser is opened for the first time. You need to manually cli ...

In JavaScript, learn how to trigger a statement only when two specific events occur simultaneously

<html> <head> <style> div{ border: 1px solid black; width: 500px; height: 500px; } </style> <script> window.onload = function(){ document.body.onmousedown = function ...

What is causing the sorting table to fail in React when using useState?

import React, { useState } from "react"; import "./App.css"; const App = () => { const [data, setData] = useState([ { rank: 1, name: "John", age: 29, job: "Web developer", }, { rank: 2, name: "Micha ...

JavaScript - Getting the name of a sub-class when extending the Error class

In my application, I have custom Errors that I wanted to check for later using the constructor name. However, when I extend Error in my classes, the constructor name always displays as "Error" instead of the actual name I assigned to it. I conducted some ...

Can files in a directory be listed using JavaScript without the need for HTML tags?

Currently, I am exploring ways to automate an Angular application using Protractor. During this process, I encountered a situation where I needed to retrieve a list of all the files within a specific folder. In Java, I am aware that we can accomplish this ...