jquery: centralizing progressbar growth on the page

Working with Bootstrap progress bars is a regular task for me, and I have included a small example below.

var $progress = $('.progress');
var $progressBar = $('.progress-bar');
var $alert = $('.alert');

setTimeout(function() {
    $progressBar.css('width', '10%');
    setTimeout(function() {
        $progressBar.css('width', '30%');
        setTimeout(function() {
            $progressBar.css('width', '100%');
            setTimeout(function() {
                $progress.css('display', 'none');
                $alert.css('display', 'block');
            }, 500); // WAIT 5 milliseconds
        }, 2000); // WAIT 2 seconds
    }, 1000); // WAIT 1 second
}, 1000); // WAIT 1 second

You can find the full code here.

I recently noticed a stylish progress bar on the LinkedIn website. When clicking on a link, the progress bar grows from the top center to both ends, creating a visually pleasing effect. You can observe this by visiting the LinkedIn website. If you have any ideas on how to develop a similar progress bar, please share them.

https://i.stack.imgur.com/ZbCnE.png

If you closely examine the image provided, you will notice a thin deep blue line expanding from the center-top of the page below the home and network menu items.

While there are many code samples available for YouTube-like progress bars, it's challenging to find resources specifically related to developing a progress bar like the one seen on the LinkedIn website. Feel free to discuss and share concepts on developing a progress bar similar to that of the LinkedIn site. Thank you.

Answer №1

I find it disappointing that you haven't made an effort with this question.

Nevertheless, you can achieve the desired effect using CSS transitions.

Check out this demo on JSFiddle

In the demonstration provided, a transition is specified for the loader element, named square

<div id="square"></div>

The CSS code used is as follows:

#square {
    width: 10px;
    height: 10px;
    margin: 100px; /*for centering purposes*/
    margin-left:200px;
    float: left;
    background: blue;
    -webkit-transition: width 1s, height 1s, margin 1s;
    -moz-transition: width 1s, height 1s, margin 1s;
    -ms-transition: width 1s, height 1s, margin 1s;
    transition: width 1s, height 1s, margin 1s;
}

To simulate loading status, the hover attributes are set to increase size and reposition the square.

#square:hover {
    width: 1000px;
    margin-left: -200px;
}

By experimenting with these settings, you can accomplish your intended goal.

For further information, you may want to refer to this post: Expand div from the middle instead of just top and left using CSS

Edit: Consider refining your use of Javascript to implement progress attributes, and make sure to optimize your setTimeout functions.

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 POST request is unsuccessful because the GET request is restricted

I'm encountering an issue with a WebMethod in my code behind that I am calling using AJAX. The method functions properly when using a GET request, but I would like to switch to using POST instead. Additionally, I am unsure why the POST request is not ...

Unable to retrieve JSON data from the given URL

Here is the JSON data I have: { "status": "ok", "count": 1, "data": { "6217895": { "clan": { "role_i18n": "Saha Komutanı", "clan_id": 16682, "role": "commander", ...

drag and drop feature paired with additional textarea below

query 1: How can I make the bottom-left textarea move together with the top-left textarea when I drag it down? query 2: What is the solution to prevent the left-bottom textarea from moving when I drag down the top-right textarea? http://jsfiddle.net/4BX6 ...

The vertical baseline alignment is not functioning as expected

In my setup, I have a straightforward configuration: <button> Lorem </button> <input type="text" value="Ipsum"> both positioned side by side with the help of display: inline-block: button, input{ height: 34px; line-height: ...

Utilizing a drop-down menu to display two distinct sets of data tables

After spending some time on my WordPress site, I've encountered a problem that has me feeling stuck. Currently, I have two functioning datatables which are displaying one on top of the other on the page. Additionally, there is a dropdown selection box ...

When trying to append in jQuery, the error "JQuery V[g].exec is not a

Attempting to create a script that adds a table to a div within the website using the following function: function generateTable(container, data) { var table = $("<table/>"); $.each(data, function (rowIndex, r) { var row = $("<tr/>"); ...

Tips for managing URL parameters in a search box

Could someone assist me in understanding how these codes will work? I am aware that they are not functioning codes. My main issue is figuring out how to pass the URL parameters for name and start date. I would like to create a search button where if you ty ...

When a button is clicked, load two separate pages into two distinct divs at the same time

$('#menuhome').click(function(){ $('#leftcolumncontainer').load('pages/homemenu.php'); }); the code above is used to load the home menu on the left side. Now, let's add the following: $('#menu ...

Retrieve the value of a PHP array within a for loop and transfer it to JQuery

*edited format I came across a PHP code for a calendar on the internet and I am currently working on implementing an onclick event that captures the date selected by a user as a variable (which will be used later in a database query). At this point, my g ...

How to eliminate escape characters in Jquery Post requests

I've come across several questions similar to mine, but I haven't found a satisfactory answer yet. My issue is as follows: I'm trying to convert a JQuery object into a Json String and then send this string to a PHP webpage. The sending part ...

Ways to Customize <td> Elements Within a <table> Container

Currently, I am utilizing jsp along with css to style the <td> within the <table> tag. My desired code format is shown below: https://i.sstatic.net/WJjA8.png However, what I am currently receiving is: https://i.sstatic.net/bLyvd.png #beng ...

PHP Calculator with Dynamic Calculations

I need to create an order form that updates the tax and total automatically once a quantity is entered into the text box. Should I use PHP or JavaScript for this functionality? Let's assume, for instance, that the tax rate is 0.3% My requirements: ...

Waiting for the listener script to finish its task in an Ajax call and then informing the user

I have developed a unique program that allows users to submit test cases from a specific webpage (main.php). The webpage triggers an ajax request to insert user data into MySQL using the file insert.php, with the value done=0. Subsequently, there is a list ...

How can I eliminate the scrollbar from appearing on all browsers when visiting my website?

I've encountered an issue while building my portfolio with React.js. I'm having trouble removing the scrollbar. I've attempted using overflow: hidden for the parent element and overflow: scroll for the child div, but it's not producing ...

Spring controller experienced a 404 not found error when making a jQuery AJAX call

I am new to Spring and I have generated a JSON as shown below: [ { "customer" : "16", "project" : "19", "phase" : "47", "approver" : "5", "date1" : "", "date2" : "", "date3" : "", "date4" : "", "date5" : "", "da ...

React's struggle with implementing flexbox functionality

Struggling to implement a calculator using React and flexbox, but running into issues with my flexbox layout. I've attempted to troubleshoot using the Chrome Dev Tools but haven't made any progress. import React, { Component } from "react"; imp ...

Building a service operation for an untyped custom data service provider entity without relying on entity framework

In my C# project, I have created a custom Untyped Data Service Provider using OData. All required providers and interfaces have been implemented. Entities are dynamically specified during metadata creation only. Neither EDMX nor Reflection providers ...

Goodbye.js reliance on lodash

In my search for the most lightweight and speedy jQuery implementation for server-side NodeJs, I've come across Cheerio as the best option. However, I've noticed that Cheerio has a code-size of around 2.6 MB, with approximately 1.4 MB attributed ...

Utilizing next/image as a backgroundImage in a div container

Currently, I am working with nextjs and I am trying to set a background Image for a specific div using next/image. Most of the sources I found only explain how to implement full screen background images with next/image, not for a single div. I stumbled upo ...

Troubleshooting: :before element not being hidden by jQuery slidetoggle()

My elements are all behaving correctly with the slidetoggle() function, except for my li:before class. I've attempted to manipulate the overflow, visibility, display, and other properties of both the :before pseudo-element and the li element, but the ...