Arranging progress bars between various nodes using HTML and CSS

I am currently facing a challenge in creating a stepping wizard form layout that features a bar at the top of the page. This bar displays a dynamic number of steps (nodes) and progress bars that connect these nodes. However, I am encountering difficulties in getting the progress bars and nodes to work harmoniously.

The main objective is to evenly space out each node horizontally on the page (which is working well with flexbox) and have the progress bars smoothly filling the gaps between the nodes.

At the moment, my approach involves using an <li> element to contain each pair of progress bar and <a> tags. Unfortunately, the layout is not aligning as desired, with the progress bars failing to fluidly fill the empty space between the <a> tags.

My question is: Is this the most effective way to structure this layout?

Before proceeding further, I want to ensure that this approach is optimal for achieving the desired layout.

EDIT 1 (Goal clarification):

I aim to replicate the layout shown in the image linked below:

https://i.sstatic.net/xB80I.png

In this image, both the progress bar and the red <a> node reside within the same <li>. Although I have set the progress bar to a width of 90% in the example, the ultimate goal is to assign a width solely to the red <a> node and have the progress bar seamlessly fill the remaining space.

Here is the HTML and SCSS code I am currently using:

<div class="panel panel-default">
  <div class="panel-heading">
    <div class="panel-title">Project Milestones</div>
  </div>
  <div class="panel-body">
    <ul class="milestone-bar">
      <li>
        <div class="progress project-progress">
          <div class="progress-bar" role="progressbar" aria-valuenow="100.0" aria-valuemin="0" aria-valuemax="100" style="width: 100.0%;">
            100%
          </div>
        </div>
        <a href="/projects/24?milestone=18">Milestone 1</a>
      </li>

      <li>
        <div class="progress project-progress">
          <div class="progress-bar" role="progressbar" aria-valuenow="100.0" aria-valuemin="0" aria-valuemax="100" style="width: 100.0%;">
            100%
          </div>
        </div>
        <a href="/projects/24?milestone=39">Milestone 3</a>
      </li>

      <li>
        <div class="progress project-progress">
          <div class="progress-bar" role="progressbar" aria-valuenow="50.0" aria-valuemin="0" aria-valuemax="100" style="width: 50.0%;">
            50%
          </div>
        </div>
        <a href="/projects/24?milestone=48">Milestone 2</a>
      </li>
    </ul>
  </div>
</div>
ul.milestone-bar {
  padding: 0;
  margin: 0 0 15px 0;
  display: flex;
  li {
    width: 100%;
    list-style: none;
    display: inline-block;;
    a {
      width: 30px;
      height: 30px;
      font-size: 12px;
      border-radius: 15px;
      background-color: red;
      float:right;
      &:hover {
        background: none;
        border: 4px solid blue;
      }
      &:active {
        background-color: darkblue;
      }
      &:focus {
        background-color: green;
      }
    }
    .project-progress {
      background-color: #d3d3d3;
      display: inline-block;
      margin: 0;
    }
  }
}

Do you think I am heading in the right direction with this setup?

Here is a snippet of the code above:

ul.milestone-bar {
  padding: 0;
  margin: 0 0 15px 0;
  display: flex;
}
ul.milestone-bar li {
  width: 100%;
  list-style: none;
  display: inline-block;
}
ul.milestone-bar li a {
  width: 30px;
  height: 30px;
  font-size: 12px;
  border-radius: 15px;
  background-color: red;
  float: right;
}
ul.milestone-bar li a:hover {
  background: none;
  border: 4px solid blue;
}
ul.milestone-bar li a:active {
  background-color: darkblue;
}
ul.milestone-bar li a:focus {
  background-color: green;
}
ul.milestone-bar li .project-progress {
  background-color: #d3d3d3;
  display: inline-block;
  margin: 0;
}
<div class="panel panel-default">
  <div class="panel-heading">
    <div class="panel-title">Project Milestones</div>
  </div>
  <div class="panel-body">
    <ul class="milestone-bar">
      <li>
        <div class="progress project-progress">
          <div class="progress-bar" role="progressbar" aria-valuenow="100.0" aria-valuemin="0" aria-valuemax="100" style="width: 100.0%;">
            100%
          </div>
        </div>
        <a href="/projects/24?milestone=18">Milestone 1</a>
      </li>

      <li>
        <div class="progress project-progress">
          <div class="progress-bar" role="progressbar" aria-valuenow="100.0" aria-valuemin="0" aria-valuemax="100" style="width: 100.0%;">
            100%
          </div>
        </div>
        <a href="/projects/24?milestone=39">Milestone 3</a>
      </li>

      <li>
        <div class="progress project-progress">
          <div class="progress-bar" role="progressbar" aria-valuenow="50.0" aria-valuemin="0" aria-valuemax="100" style="width: 50.0%;">
            50%
          </div>
        </div>
        <a href="/projects/24?milestone=48">Milestone 2</a>
      </li>
    </ul>
  </div>
</div>

Answer №1

After making some adjustments to your code, here are the changes I implemented:

  1. I added flex to each li element to create nested flex children:

    ul.milestone-bar li {
      width: 100%;
      list-style: none;
      display: flex;
    }
    
  2. I included flex: 1 to make it flex to the entire width and vertically align it to the center using align-self: center for your project-progress like this:

    ul.milestone-bar li .project-progress {
      background-color: #d3d3d3;
      display: inline-block;
      margin: 0;
      flex: 1;
      align-self: center
    }
    
  3. The progress bar style was also added:

     ul.milestone-bar li .project-progress .progress-bar {
        background: #0095FF;
        text-align: center;
     }
    
  4. In addition, I made adjustments to the milestone-bar for a better appearance:

    ul.milestone-bar li a {
      width: 60px;
      height: 60px;
      font-size: 10px;
      border-radius: 50%;
      background-color: red;
      text-align: center;
      line-height: 60px;
    }
    ul.milestone-bar li a:hover {
      background: none;
      border: 4px solid blue;
      line-height: 52px;
    }
    
  5. Lastly, I applied box-sizing: border-box to all elements on the page for better border management and to prevent 'jumps' when hovering.

* {
  box-sizing: border-box;
}
ul.milestone-bar {
  padding: 0;
  margin: 0 0 15px 0;
  display: flex;
}
ul.milestone-bar li {
  width: 100%;
  list-style: none;
  display: flex;
}
ul.milestone-bar li a {
  width: 60px;
  height: 60px;
  font-size: 10px;
  border-radius: 50%;
  background-color: red;
  text-align: center;
  line-height: 60px;
}
ul.milestone-bar li a:hover {
  background: none;
  border: 4px solid blue;
  line-height: 52px;
}
ul.milestone-bar li a:active {
  background-color: darkblue;
}
ul.milestone-bar li a:focus {
  background-color: green;
}
ul.milestone-bar li .project-progress {
  background-color: #d3d3d3;
  display: inline-block;
  margin: 0;
  flex: 1;
  align-self: center
}
ul.milestone-bar li .project-progress .progress-bar {
    background: #0095FF;
    text-align: center;
}
<div class="panel panel-default">
  <div class="panel-heading">
    <div class="panel-title">Project Milestones</div>
  </div>
  <div class="panel-body">
    <ul class="milestone-bar">
      <li>
        <div class="progress project-progress">
          <div class="progress-bar" role="progressbar" aria-valuenow="100.0" aria-valuemin="0" aria-valuemax="100" style="width: 100.0%;">
            100%
          </div>
        </div>
        <a href="/projects/24?milestone=18">Milestone 1</a>
      </li>

      <li>
        <div class="progress project-progress">
          <div class="progress-bar" role="progressbar" aria-valuenow="100.0" aria-valuemin="0" aria-valuemax="100" style="width: 100.0%;">
            100%
          </div>
        </div>
        <a href="/projects/24?milestone=39">Milestone 3</a>
      </li>

      <li>
        <div class="progress project-progress">
          <div class="progress-bar" role="progressbar" aria-valuenow="50.0" aria-valuemin="0" aria-valuemax="100" style="width: 50.0%;">
            50%
          </div>
        </div>
        <a href="/projects/24?milestone=48">Milestone 2</a>
      </li>
    </ul>
  </div>
</div>

Feel free to share your thoughts on these changes. Thank you!

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

Grid system that adapts without distortion

My goal is to create a grid that maximizes the number of elements in its width without stretching them to fit the entire window. That's why I'm utilizing CSS grid with the auto-fill property, which is almost achieving the desired outcome. I want ...

CSS3 :not does not exclude a selector by id

Hello wonderful community of Stackoverflow, Here is my CSS code: .text:not(#overview > *) { margin-top: 10px; margin-bottom: 10px; } I am trying to apply a 10px top and bottom margin to everything with the class "text", except for elements ma ...

What is the best way to automatically adjust the size of this HTML Menu to match the width of its

I am in the process of converting a Drupal 6 theme to Drupal 7 and I'm encountering some difficulties with this particular section. Below is the HTML code snippet: <ul id="nav" class=" scaling-active scaling-ready"> <li><a href="/demos ...

Combining CSS to Align Two Form Fields Side by Side

I recently came across an online form and I'm attempting to customize it by aligning the phone and email text fields next to each other. I have made some progress, but the formatting is not quite right. The fields are too small and adjusting their siz ...

Arranging mat-checkboxes in a vertical stack inside a mat-grid-tile component of a mat-grid-list

I'm looking to create a grid list with 2 columns, each containing 2 checkboxes stacked vertically. While I found this helpful question, it still involves a lot of nested divs. Is there a cleaner way to achieve this layout? Here's how I currentl ...

Ways to ensure a video completely fills the frame

I am experiencing an issue where the video in the main div of my home page does not fully fill the div right away - I have to refresh the page for this to happen. As a result, there is black space on the left and right sides. Interestingly enough, this pr ...

When the button is clicked, request the total count of elements in the array

Is there a way to log the index of an array element when clicked? I have a large array with over 100 elements: var cubesmixed = []; var cubes; for(var i = 0; i < 143; i++) { cubes = paper.rect(Math.floor(Math.random()*2000), Math.floor(Math.random ...

Some sections of the HTML form are failing to load

I'm currently following a tutorial and applying the concepts to a Rails project I had previously started. Here's my main.js: 'use strict'; angular.module('outpostApp').config(function ($stateProvider) { $stateProvider.sta ...

Is Ursina the right choice for web development?

Looking for a method to compile Ursina for HTML5 using WebAssembly or another technology? I am seeking to make my Ursina Game compatible with Linux & Mac (and potentially Android/iOS with webview), but the current cross-platform compilation options for Py ...

Randomize elements with the click of a button

Every time the page refreshes, the words shuffle around. For instance, "May I# know# your name?" shuffles to "know May I your name". To display the correct sentence with "#" as "May I know your name?", click the SHUFFLE button to trigger the shuffling. HT ...

Pass the html form data to a PHP variable

I need assistance with updating a PHP variable with the value of an HTML form submission. Here is the code snippet: <form action="callback2.php" method="POST"> Enter Phone Number: <input type="text" size="10" name="nummerb" id="nummerb"> <i ...

Display a variety of body background images depending on the user's selection

Is it possible to change the background of the page when an option is selected from a dropdown menu? Additionally, can this be achieved with a smooth fade in and fade out animation? Here is a code example on CodePen. body ...

Styling group headers within an unordered list using pure CSS - possible?

Hey there, I'm looking to spruce up my UL by adding group headers. Here's a sneak peek at the structure I have in mind (keep in mind this is generated dynamically from a database): <ul> <li class='group group-1'> < ...

An introduction to utilizing .keypress() in jquery

I'm exploring the use of .keypress() to allow users to press enter and trigger a button click on my modal (which closes the modal). When I initially code it as: $(document).keypress(function () { console.log('keypress'); }); it works, but ...

The fixed background-attachment feature does not function properly in Chrome when it is contained within a scrolling div

Essentially, if a background image is placed within a scrolling div, it will no longer remain fixed and will revert back to scrolling: CSS: <div class="wrapper"> <span></span> </div> HTML: html, body{ width: 100%; height: ...

Step-by-step guide to implementing a month and year date-picker in Mozilla Firefox

I'm looking to create input fields where users can add the month and year. I tried using the code below, but unfortunately Mozilla Firefox doesn't support it. <input type="month" id="start" name="start"> Does ...

Unable to render a child div completely opaque using the opacity attribute

I am currently working on a popup feature that, when displayed, will blur the background of the page to a grey color. The .cover element is responsible for this overlay effect. Unfortunately, I am facing issues overriding its default opacity:0.6; property ...

The controller and node js request associated are invisible to my HTML page

Here is my HTML code. I have just created a unique controller for a specific part of the code. <div class="mdl-grid" ng-controller="ValueController"> <div class="mdl-card mdl-shadow--4dp mdl-cell--12-col"> <div class ...

Adjust transparency according to the information extracted from the AnalyserNode

Currently, I am exploring ways to animate text opacity based on the volume of an audio file. While browsing online, I came across this specific codepen example, which showcases a similar concept. However, as I am relatively new to JavaScript, I find it ch ...

Performing two ajax calls within a non-existent div that has only just been appended

I've been developing a website similar to 9gag. I attempted to incorporate a voting feature created by someone else, as I'm not well-versed in AJAX requests, but it just doesn't seem to be functioning. My index.php file fetches five posts f ...