The progress bar has ceased functioning when the "display: inline-block;" property is applied

Having trouble with the progress bar for a new job project. The issue arises when trying to display the bar and number on the same line using inline-block - it causes the filling of the bar to disappear. When not using this property, the bar looks correct but the number is not aligned correctly.

Here's the HTML code:

<div style="width:100%;">
    <div class="progress">
        <div class="progress-bar" style="width:{{value}}%"></div>
    </div>
    <span class="value">{{value | number:0}}</span>
</div>

And here's the CSS code:

.progress {
    height: 0.3rem;
    width: 90%;
    display: inline-block;
}
.value {
    float: right;
    display: inline-block;
    vertical-align: top;
}

Any insights on why this issue is happening would be greatly appreciated. Thanks in advance!

Answer №1

Have you considered utilizing the capabilities of FlexBox?

If you're not familiar with it, here's a helpful guide: https://css-tricks.com/snippets/css/a-guide-to-flexbox/

You can achieve various layouts with FlexBox like demonstrated in this example: https://jsfiddle.net/nL3pr8vw/2/

* {
  padding: 0;
  margin: 0;
}

.load {
  display: flex;
  justify-content: left;
  align-items: center;
  background: grey;
  padding: 5px;
  margin: 10px;
  width: 300px;
  border-radius: 5px;
}

.bar {
  width: 45%;
  background: red;
  border-top-right-radius: 5px;
  border-bottom-right-radius: 5px;
  display: flex;
  justify-content: center;
  align-items: center;
  height:25px;
}

p {
  color: white;
  font-family: Arial;
  font-size: 0.5em;
}
<div class="load">
  <div class="bar">
    <span class="count"><p>45%</p></span>
  </div>
</div>

With this code snippet, feel free to experiment by rearranging the divs and tweaking the FlexBox properties in the CSS to customize your layout!

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

CSS: Deciphering the Hidden Message in this Code Snippet!

Update In my CSS file, I encountered a conflict with the following snippets. When I include this section: <style type="text/css"> ::selection{ background-color: #E13300; color: white; } ::moz-selection{ background-color: #E13300; colo ...

Establishing the default scroll position in tables using React.js

How can I set the initial scroll in ReactJS Material-UI tables? I'm working with a table that has numerous columns and I would like to have specific columns in view automatically without having to scroll, essentially establishing an initial scroll. I ...

Show a div once all its content has been fully loaded

I have a section on my webpage that includes images, text, and links. It functions as a carousel. My goal is to show the section only after all content has loaded. I am looking to transition from opacity 0 to opacity 1 with a fade-in effect. Here is the ...

Modifications to the HTML output in ASP.Net made through JavaScript are swiftly reversed

I have a website where I display a list of properties, such as houses. The layout of this list is created using CSS. I recently created a second CSS class to properly align the properties/houses in two columns. Previously, I achieved this by pressing a but ...

What could be causing the image to not show up in Angular?

I created a table in my demo with the assistance of this provided example. Within this example, the first column contains an image labeled as "edit image" (taken from bootstrap). When I attempted to replicate the same example in my plunker, which already ...

Sass includes line-specific comments to indicate where a certain definition is located

There seems to be a strange occurrence when I save my file and it's generated by Compass. Each declaration is followed by a comment indicating the line of the sass file, like this: /* line 55, ../sass/app.scss */ In addition, my config.rb file conta ...

HTML5 Websocket communication lag when using node.js

Hello everyone, thank you for taking the time to read this. I am currently utilizing NodeJS with the WS module on the server side and HTML5 WebSocket API in Firefox on the client side. The operating system being used is Windows 7 64 bit. I have encountered ...

Utilize jQuery to toggle and swap between multiple classes

I am looking to implement a feature where clicking on certain cells will add and switch classes, similar to a calendar schedule. I attempted the code sample below, but it did not successfully toggle each class. The desired outcome is to switch classes li ...

Experiencing a dependency injection issue when attempting to include ngRoute into the dependencies

In my AngularJS app, I have included the ngRoute dependency for routing and created a service for making REST calls. However, when I try to inject the dependency with ngRoute, I encounter the following error: angular.min.js:6 Uncaught Error: [$injector:mo ...

Arrange CSS to distribute list items across two rows with an unlimited number of items

I need my list items to be arranged in 2 rows like the following: item 1 item 3 item 5 item 7 item 9 .... item 2 item 4 item 6 item 8 ...... My CSS skills are not great, so I am struggling to find a solution for this. I have at ...

Is there a way to make sure that my submit button aligns perfectly with the text beneath it

I am new to coding and I need help aligning my submit button with the text "You can contact Armando through his freelance portfolio on Upwork by clicking...". Can anyone assist me with this? .topnav { background-color: #333; overflow: hidden; } .to ...

Ensure that the CSS element pseudo-class does not override the styling of its child

Looking to style an anchor element that contains other HTML elements. Here is the basic code structure: HTML: <div class="container" id="sub-menu"> <div class="row" data-bind="foreach: subMenu"> ...

Angular component causing a method to be called before a variable is changed

Currently, I am in the process of refactoring code within an Angular 1.5.8 application to utilize components. (Following similar steps outlined in this guide: ) The basic cases are functioning as expected. However, I have encountered a problem when my co ...

It is crucial to refrain from making any CSS adjustments in Google Chrome

So I encountered an interesting issue on my website. There are two CSS files - main.css and bootstrap.css, with some overlapping styles. I made a change in the bootstrap.css file by adding !important next to the property. Surprisingly, in Firefox, the chan ...

I'm seeking a way to access the input element within the InputGroup component of BlueprintJs in my

The BluePrintJS React InputGroup component offers a convenient user interface for modern applications. However, it does not provide direct access to the internal <input> element. There are two primary reasons why I need to access the input element: ...

When attempting to capture an element screenshot as PNG, a TypeError occurs indicating that the 'bytes' object is not callable

Can someone please help me figure out how to save a screenshot of a specific element in Selenium using Python3? Here is the code I am trying: from selenium import webdriver import pyautogui as pog import time options = webdriver.ChromeOptions() options ...

Explore the search function that scours through every external HTML page

I am in the process of creating a website and I need to implement a search functionality. My website consists of several HTML pages such as index.html, about.html, contact.html, etc. The search bar is located in the navigation menu on every page. I would l ...

What is the reason for index always being not equal to 0?

<script> var index = 0; $.getJSON("./data/data.json", function(json) { $.each(json, function(data) { var html = ""; if(index == 0) { console.log(index + " fir ...

Display text in a scrolling manner once it exceeds the container's boundaries

I've been searching high and low for a solution to my problem. I have a div that displays the information about who's playing on an online radio station. The width of the div is set to 200px, but when the artist and song title are too long, the ...

Transforming the appearance of web elements using jQuery (graphic)

While there are numerous resources on changing CSS with jQuery, I seem to be having trouble getting my image to hide initially and show up when a menu tab is clicked. Any help would be greatly appreciated! ;) h1 { text-align: center; } .Menu { widt ...