What's the solution for aligning these progress bars side by side if floating them doesn't produce the desired result?

I am looking to place two progress bars next to each other, but I have tried using float: left and inline-block without success.

I am open to a solution using flex, but I believe there must be a simple fix for this issue.

Here is a link to the fiddle for reference: https://jsfiddle.net/8j606f85/

HTML:

<div class="row">
  <div class="full bar">
    <div class="progress bar">
      <div class="text">
        Text
      </div>
    </div>
  </div>
  <div class="full bar">
    <div class="progress bar">
      <div class="text">
        Text
      </div>
    </div>
  </div>
</div>

CSS:

.row {
  //????????
}

.full.bar {
  position: relative;
  display: block;
  max-width: 50%;   
  border: none;
  margin: 0.5em 0em 0.5em;
  box-shadow: none;
  background: rgba(0, 0, 0, 0.1);
  padding: 0em;
  border-radius: 0.25rem;
}

.progress.bar {
  display: block;
  line-height: 1;
  position: relative;
  width: 50%;
  min-width: 2em;
  background: #888888;
  border-radius: 0.25rem;
  z-index: 200;
  height: 1.25em;
}

.text {
  white-space: nowrap;
  position: absolute;
  width: auto;
  font-size: 0.9375em;
  top: 50%;
  right: 0.5em;
  left: auto;
  bottom: auto;
  color: rgba(255, 255, 255, 0.7);
  text-shadow: none;
  margin-top: -0.5em;
  font-weight: bold;
  text-align: left;
}

Answer №1

Make sure to include float:left and update max-width to width in your CSS for the .full.bar element.

.full.bar {
  position: relative;
  /*display: block; not needed - set by default */
  width: 50%;
  border: none;
  margin: 0.5em 0em 0.5em;
  box-shadow: none;
  background: rgba(0, 0, 0, 0.1);
  padding: 0em;
  border-radius: 0.25rem;
  float:left
}
.progress.bar {
  /*display: block; not needed - set by default */
  line-height: 1;
  position: relative;
  width: 50%;
  min-width: 2em;
  background: #888;
  border-radius: 0.25rem;
  z-index: 200;
  height: 1.25em;
}
.text {
  white-space: nowrap;
  position: absolute;
  width: auto;
  font-size: 0.9375em;
  top: 50%;
  right: 0.5em;
  left: auto;
  bottom: auto;
  color: rgba(255, 255, 255, 0.7);
  text-shadow: none;
  margin-top: -0.5em;
  font-weight: bold;
  text-align: left;
}
<div class="row">
  <div class="full bar">
    <div class="progress bar">
      <div class="text">
        Text
      </div>
    </div>
  </div>
  <div class="full bar">
    <div class="progress bar">
      <div class="text">
        Text
      </div>
    </div>
  </div>
</div>

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

HTML Multi-Column List Box

Can a List Box be created with List Items displayed in Multiple Columns? I know there are other options available, but I'm curious if this is achievable using the <select> tag ...

Creating a dynamic canvas with a three-dimensional model using three.js: A step-by-step guide

I'm currently developing a website where I have integrated a canvas element to display a 3D object (specifically, a cube) using three.js. The canvas is housed within a div, following the guidelines found in various documentation. The issue arises wh ...

Determine if a paragraph contains a specified value using jQuery

I need to only select the checkboxes that do not have a value in the paragraph. Some mistake seems to be causing all the checkboxes to be marked when I click the button (Value > 0). Can you spot where I went wrong? $("input[id*='btnValue']" ...

Difficulty with collapsing icon in Bootstrap's navigation bar

I am in the process of building a bootstrap website and facing an issue with the collapsible navigation bar. The nav toggle button is always visible, but I want it to only appear when the nav bar goes to a medium size. How can I achieve this? The code sni ...

Having trouble with your CSS dropdown menu?

I've been struggling to implement a dropdown menu on my website following an online tutorial. Despite following the steps, I can't seem to get it working. It's frustrating because I want to move on to backend development. Hoping someone can ...

HTML/ModX styling for selected textboxes

I am looking to enhance the style of my search-box, which is similar to the one on THIS website. While I have tried using :active, the effect only lasts for a brief moment. Currently, my code is heavily influenced by modX terms, but I will still share it h ...

jquery activating the toggle function to switch between child elements

I'm facing a challenge where I can't use .children() in this scenario, as it won't work since the elements aren't technically children. Here's the snippet of HTML that I'm working with: <p class="l1">A</p> ...

"Return to previous page" feature

I am having difficulty figuring out how to implement the "go back" function for the page. For instance, I have pages A, B, C, and D. The possible switching between pages is as follows: A -> (B <-> C) -> A or D -> (B <-> C) -> D (w ...

What is the best way to get rid of the blue color border around the input fields on Micromax A110 and Sony Ericsson phones?

I am currently experiencing an issue with my application where a blue outline color is appearing on the input field for Micromax A110 and Sony Ericsson mobile devices, while all other Android devices do not have this problem. I am unsure of the exact reaso ...

How can you assign a strokeStyle color to a Canvas using a CSS property?

Our team is currently working on an Angular2 / Ionic 2 project where we have implemented a HTML Canvas element that allows users to draw on it. One challenge we are facing is how to set the Canvas strokeStyle property using a color provided by a CSS style. ...

Align the bottom borders to the lowest content on each line

I am working on designing my homepage using HTML, CSS, JSP, and JavaScript, focusing on the sale of musical instruments and facilitating communication among users. Right now, I am in the process of creating a site-map for my menu configuration chart using ...

Is it possible to use React and Material-UI to make a paper element extend to full width beyond the boundaries of a Container?

Assuming I have the following code snippet: <Container maxWidth='lg'> <Grid container spacing={3}> <Grid item xs={12} md={6} > <Image src="/img/undraw_programming_2svr.png" color='transparent' ...

Preventing Line Breaks in CSS Grid Autofil Experiment: A Guide

My journey in grasping the concepts of CSS Grid starts with this exploration. As you adjust the display width, observe how the text "Client code" switches between being displayed on one line and then breaking onto a new line repeatedly. .grid-container ...

Utilizing Bootstrap, the layout structure consists of 4 columns for desktop, 3 columns for small laptops, 2 columns for tablets, and

I need assistance with setting up responsive columns in my HTML code using Bootstrap. Specifically, I want 4 columns per row on desktop, 3 columns per row on tablet, and 2 columns per row on mobile devices. Despite searching on Stack Overflow, I couldn&apo ...

The children's className attribute can impact the parent element

As I work on creating a card object, I envision it with the className .card that is styled in CSS as follows: .card img{position:absolute; width:150px; height:160px} I want only the images inside my div to overlap each other while not affecting the divs ...

My goal is to develop a table that is both able to be resized and easily repositioned

I've been working on a project to develop an interactive table that can be manipulated, resized, and repositioned within a canvas. The code snippet below shows my attempt at creating this table on the canvas: var canvas = document.getElementById("dra ...

Why is the toggle list not functioning properly following the JSON data load?

I attempted to create a color system management, but as a beginner, I find it quite challenging! My issue is: When I load my HTML page, everything works fine. However, when I click on the "li" element to load JSON, all my toggle elements stop working!!! ...

jquery to create a fading effect for individual list items

I have a group of items listed, and I would like them to smoothly fade out while the next one fades in seamlessly. Below is the code I've been working on: document.ready(function(){ var list_slideshow = $("#site_slideshow_inner_text"); ...

Modifying input values in AngularJS/HTML

I'm encountering an issue with the ng-repeat function in AngularJS within my HTML code. The problem is that when I change the input with the ID 'add-price' in one cartproduct, it simultaneously changes in all other cartproducts as well. For ...

Angular: Customizing table cell color based on condition

I am having trouble with changing the cell color of an object in my html table if a certain variable changeColor is true. I am utilizing angular for this task. <tr ng-repeat="list in results"> <% if (!{{list.changeColor}} ) %> <% { ...