Positioning the progress bar at the bottom of the parent div in Bootstrap

My goal is to place a progress bar at the bottom of a parent div using position:absolute and bottom:0, but it seems like these styles are causing conflicts with the progress bar itself.

<div class="progress" style="position:absolute; bottom:0px;">
        <div id="progress" class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="min-width: 2em;">
        0%
        </div>
</div>

I have provided an example in this fiddle: https://jsfiddle.net/DTcHh/12732/

Can anyone suggest the correct method to achieve this positioning?

Answer №1

The issue lies in setting the position to absolute, which prevents the width from automatically adjusting to full width.

Consider using the following approach instead:

.progress {margin: 10px;} /* Apply this style to the 'progress' class instead of the body */

<div style="position:absolute; bottom:0px;width: 100%;">
    <div class="progress">
        <div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="min-width: 2em;">0%</div>
    </div>
</div>

Check out this JSFiddle for reference

var count = 0;

$("#nextStepBtn").click(function () {
    count++;
    if (count <= 100) {
        $(".progress").children().each(function () {
            $(this).attr("aria-valuenow", count.toString()).css("width", count.toString() + "%").html(count + '%');
        });
    }
});
.progress {
    margin: 10px;
}

.progress-bottom-container {
    position:absolute;
    bottom:0px;
    width:100%;
}
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<button id="nextStepBtn" class="btn btn-default">Next step</button>
<br>
<br>
<div class="progress-bottom-container">
    <div class="progress">
        <div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="min-width: 2em;">0%</div>
    </div>
</div>
<div class="progress">
    <div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="min-width: 2em;">0%</div>
</div>

Answer №2

An issue arises when using the CSS property position: absolute with a progress bar because of its width.

To resolve this, simply assign a width of width: 96%; to the progress bar element for a properly sized progress bar.

https://example.com/css-progress-bar

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

Tips for adding animation to the div instead of the content

I have implemented a hover animation to animate the div, but unfortunately, when I added the animation to #i :hover {}, it ended up animating the words only. Moreover, the cursor transforms into a pointer solely when hovering over the words instead of the ...

I am struggling to get the pop-up to close using the current code. I suspect that the issue might be related to the variable I was previously using in WordPress. I have made changes but the pop-up

While delving deeper into the realm of Javascript, I encountered a stumbling block with a single popup intended for the main page of a WordPress website I am constructing. Despite my attempts to modify the code's variables, they seem unyielding. Surpr ...

Having trouble with animating the background color of an input button using jQuery?

I'm completely confused as to why the background color isn't changing despite investing a significant amount of time into it: <input type="button" class="front-consultation-btn" value="Get A Free Consultation"> <script> $(' ...

The challenge of styling table borders with CSS

Can anyone help me with a problem I'm having while trying to create simple borders on a table? The border appears bold in the second row and last row, does anyone know why this is happening? https://i.sstatic.net/bCuhK.jpg Just a note: when I checke ...

Tips for achieving a uniform border in Bootstrap's input-group when adding an image

I am working on creating a search box within a navbar and encountering an issue with the border style: https://i.sstatic.net/DCMpX.png My challenge lies in achieving consistent borders - I aim for the icon to have the same border as the "Search..." box w ...

Using a percentage width on a <div> element with the "overflow-x: scroll" property does not seem to be functioning properly, even when encapsulated within

My code includes a div within another div, taking up 50% of the page's width: <div id="mainContainer" class="mainContainer"> <div id="scroller" class="scrolling"> <!-- items here should make the div really long --> & ...

The background color and border are not showing up in the <div> element

I am encountering an issue with 3 inline <div> elements where the one on the far left is not displaying the light blue background and black border that it should have. HTML: <!DOCTYPE html> </html> <head> <link rel= ...

Is the menu not appearing in the header section of the HTML/CSS?

Hey there, I'm a new student diving into the world of HTML/CSS. I've been working on creating a page layout, but for some reason my menu links are appearing under the header section instead of within it. I'm a bit confused and could really u ...

How can I avoid anti-aliasing in browsers when enlarging images?

Back in April 2012, Google's Chart Image API became deprecated but it was possible to generate QR codes using it. Although I know that I can adjust the size of the image produced by the API, I prefer to simply use CSS along with the width and height ...

Avoid having the java applet destroyed when the container is hidden

I am working with multiple DIVs, each containing text, a java applet (unfortunately...) and buttons. I am currently creating a search function to dynamically show and hide these DIVs. However, whenever I use display:none on a DIV, the applet inside it se ...

Compiling SCSS to CSS in Vue.js is a breeze

I am working on a vue js project that includes scss files. My goal is to compile these scss files into css and store them in the public folder. How can I achieve this? Should I make changes to the vue.config.js file? const path = require('path'); ...

What is the method for squaring the sides of the top border?

Can the top border be squared (straightened) as shown in the image below? https://i.sstatic.net/7GKhj.png .nav.nav-tabs.custom-nav-tabs .nav-link { border-radius: 0px; } .nav.nav-tabs.custom-nav-tabs .nav-link.active { border-top: 2px solid gr ...

Issue with Bootstrap container's max-width not functioning

After implementing the code in the following manner: <link href="css/bootstrap.css" rel="stylesheet" type="text/css"> <link href="css/bootstrap-responsive.css" rel="stylesheet" type="text/css"> <style type="text/css"> .con ...

Applying CSS to Align List Items to the Left with Word Wrap

Over at my blog page qavalidation.com, I am faced with an issue related to the alignment of vertical menus with links. When word wrap is applied, there seems to be a misalignment in the left indentation. Can someone provide guidance on the correct CSS sty ...

Ngx-bootstrap tooltips failing to display

In my Angular 7 project, I am utilizing ngx-bootstrap 4.0.1 alongside Bootstrap 4.3.1, and I have a requirement to incorporate tooltips in certain elements of the application. Despite following the documentation for setup instructions, I am facing difficul ...

The Navbar-Burger in Bulma is not linking to menu items properly in Vue.js 2

I have been working on implementing a navbar for my application using Vue 2.0 and Bulma. Everything seems to be working fine on desktop screens, but on smaller screens, the burger icon appears without any elements displayed. It's just there. <temp ...

Trouble with partial page displaying incorrect CSS class

I have created CSS classes for generating circles with different colors. When I apply the CSS class in a regular HTML file, it displays correctly as expected. However, when I try to use it in an AngularJS partial page, the circle does not render properly. ...

Is the textarea's shape out of the ordinary?

Most textareas are typically rectangular or square in shape, similar to this: However, I am interested in having a custom-shaped textarea, like the example below: Is it feasible to achieve? ...

I'm confused as to why the icon color isn't changing on the Blogger homepage for each individual user

I'm experimenting with changing the eye color based on visitor count. It works perfectly fine on static posts in my Blogger, but it fails to update the eye color properly on my homepage according to the set numeric values. Instead of displaying differ ...

Using a color as a substitute for a background image on mobile devices

Is there a way to create a fallback in my CSS for changing the background image to a color when viewed on a mobile browser once the pixels reach the max-width? In the snippet below, the media query "only screen and (max-width: 600px)" works if the top bod ...