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

Prevent scrolling on both md-sidenav and md-content in AngularJS Material

Currently, I am working on a website using AngularJs Material sidenav. My goal is to make both md-sidenav and md-content appear as one page, without any scroll bars showing up when the height of one element exceeds that of the other. How can I achieve th ...

What is the reason for jQuery displaying undefined when attempting to retrieve a custom data attribute using .prop()?

In my dynamic HTML generated by JavaScript, the following code snippet is included: $(".task-status").live("click", function () { alert("data-id using prop: " + $(this).prop("data-id")) alert("data-id using data: " + $(this).data("id")) ...

The commencement of setTimeout relies on my decision to halt the page's operation

During a form submission, my jQuery AJAX function is used to query the amount of data uploaded from a file. This information is then utilized in creating a progress bar. Here is an example of my JavaScript file: var formSubmitted = ''; var count ...

Utilizing HTML and JQuery to clear form values

I am attempting to transfer the form data along with an additional parameter "id" to the server using Python and Google App Engine. This is my form: <form method="post" action="/" id="form1" runat="server" enctype='multipart/form-data'> ...

AJAX is currently not operational

I've spent the last couple of hours trying to troubleshoot this issue with no luck. Can anyone provide any assistance? For some reason, the table fails to load when the button is clicked. Below is the relevant code snippet from my header: <head&g ...

"Exploring the Magic of Jquery's Fadein() Animation

i have experience with writing code for a jQuery fadein effect. imagine I have an HTML element stored in a variable, like this: var sHtml="<div>Other content</<div><div id='frm'>hello</<div>"; modal.load(jQuery(sHt ...

The relative positioning is currently being obstructed

Having some trouble using position:relative to shift my logo to the left of my webpage. Oddly, moving it 20px seems to have no effect, but shifting it by 300px downwards causes it to vanish completely. Here's a snippet of my current code: .container ...

Step by step guide on inserting a message (memo/sticky note) onto an HTML page

Wondering how to accomplish this: I've designed an HTML5 homepage and I'm looking to display a message to visitors, such as "Dear visitor, I am currently on vacation from....", in the form of a memo or sticky note positioned in the top right cor ...

Error: Jsonp callback not functioning properly on Internet Explorer

I have been using JSONP to retrieve data from an API through AJAX. After testing my code on Firefox and Chrome, it has worked flawlessly in these browsers. The link I am utilizing follows this format: www.placeholder.com/foo/?jsonp=dataCallback Yet, ...

The Datatable feature is malfunctioning, unable to function properly with Javascript and JQuery

As a novice in the world of jquery/javascript, I find myself struggling with what may seem like an obvious issue. Despite following tutorials closely (the code for the problematic section can be found at jsfiddle.net/wqbd6qeL), I am unable to get it to wor ...

I would like to know the method for inserting an HTML element in between the opening and closing tags of another HTML element using

Recently, I came across a coding challenge involving a textbox. <input type="text></input> The task was to insert a new span element between the input tags using jQuery, as shown below: <input type="text><span>New span element< ...

Challenge: Integrate jQuery into Wordpress while converting a Bootstrap template

I am facing an issue with loading jQuery files from a Bootstrap template while converting it into a Wordpress theme. Despite trying various methods of enqueuing scripts in my functions.php file and even de-registering jQuery, the problem persists. Upon in ...

Tips for Implementing Multi-Level/Nested in Ajax Requests

I am currently developing a user-friendly web application with intuitive multi-level options that loads new content without the need to refresh the entire page. This is how my structure looks: /index.php /schools.html /colleges.html Within schools.html, ...

Mobile devices offer a seamless vertical scrolling experience

Here is the HTML structure I am working with: <div> <a>..</a> <i>..</i> <a>..</a> <i>..</i> <a>..</a> <i>..</i> </div> On larger screens, all elements are dis ...

When I hover over div 1, I am attempting to conceal it and reveal div 2 in its place

I need help with a CSS issue involving hiding one div on mouse hover and showing another instead. I attempted to achieve this using pure CSS, but both divs end up hidden. Would jQuery be necessary for this task? Below is the CSS/HTML code I wrote: .r ...

Is it feasible to perform a secondary sort based on Isotope?

I've successfully figured out the sort code and it's functioning as intended. I'm interested in incorporating a secondary filter option. Here is an example of my series: <div id="member1" class="sortItem" data-factor="2"> <sp ...

Update the page using Ajax without relying on jQuery

I want to implement automatic page updates without the need for a refresh using Ajax. However, most resources I've come across suggest using jQuery and PHP, which are areas of coding I am not very familiar with. My goal is to integrate Ajax into my HT ...

Tips for setting a value from an AJAX-created element into a concealed form field

There is a div that contains a button. When the button is clicked, a form appears. The div's id is then assigned to a hidden field within the form. This functionality works for the divs that are present on the page when it initially loads, but it does ...

In a lineup of items arranged horizontally, the second to the last item is perfectly centered, whereas the final item stretches out to occupy all of the leftover

I am currently working on creating a horizontal list of items: My goal is to have the second last item centered once the end of the list is reached, with the last item expanding to fill all remaining space. While I have successfully created the list of i ...

Jquery fails to display errors or provide validation feedback

I have been struggling to implement form validation on my website without using jQuery validate. Unfortunately, the code I have written is not functioning properly and is causing some CSS issues in my local environment. My main objective is to validate fo ...