Difficulty with alignment in the process of generating a vertical stepper using HTML and CSS

I'm currently working on developing a vertical stepper component using html & css with inspiration from this design. However, I've encountered some alignment issues in the css that I'm struggling to resolve.

CSS

.steps-container .step::before {
  display: inline-block;
  content: "";
  font-size: 10px;
  color: #fff;
  text-align: center;
  background-color: #e1e1e1;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  position: relative;
  right: 4px;
  top: 2px;
}

.steps-container .step.active::before {
  background-color: green;
}

.step-vertical {
  border-left: 1px solid #e1e1e1;
  margin-bottom: 5px;
  margin-left: 5px;
}

HTML

<div>
      <div class="steps-container">
        <span class="step inactive">1</span>
        <div class="step-vertical">
          <div>
            <h5 class="text-grey">label text 1</h5>
            <button>Continue</button>
          </div>
        </div>
      </div>
      <div class="steps-container">
        <span class="step active">2</span>
        <div class="step-vertical">
          <div>
            <h5 class="text-grey">label text 2</h5>
            <button>Continue</button>
          </div>
        </div>
      </div>
    </div>

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

My desired output includes having the numbers 1 and 2 inside the circle and aligning the label text next to each circle. Any suggestions on how to achieve this would be greatly appreciated.

Answer №1

Here is the desired layout: applied the :before css to span and included display: inline-block; in .step-vertical to position it beside the span.

.steps-container .step {
      display: inline-block;
    content: "";
    font-size: 10px;
    color: #fff;
    text-align: center;
    background-color: #e1e1e1;
    /* width: 20px; */
    /* height: 20px; */
    border-radius: 50%;
    position: relative;
    right: 4px;
    top: 2px;
    padding: 5px 10px;
    color: black;
    vertical-align: top;
}

.steps-container .step.active::before {
  background-color: green;
}

.step-vertical {
  border-left: 1px solid #e1e1e1;
  margin-bottom: 5px;
  margin-left: 5px;
height:200px
}

h5{margin-top: 5px;
display: inline-block;}

button{
  display:block
}

.ml-2{
  margin-left:10px
}
<div>
<div class="steps-container">
      <span class="step inactive">1</span>
      <h5 class="text-grey">label text 1</h5>
      <div class="step-vertical"> 
         <div>
           <textarea class="ml-2" name="" id=""     cols="30" rows="10">           
           </textarea>
           <button class="ml-2">Continue</button>
        </div>
      </div>       
  </div>
   <div class="steps-container">
      <span class="step inactive">2</span>
      <h5 class="text-grey">label text 2</h5>
      <div class="step-vertical"> 
         <div>
           <textarea class="ml-2" name="" id="" cols="30" rows="10">            </textarea>
           <button class="ml-2">Continue</button>
        </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

Click outside of this popup to dismiss it

I have been struggling to figure out how to make this popup close when clicking outside of it. Currently, it only closes when clicked directly on it. Your assistance in this matter is greatly appreciated. Here is the HTML code: <h2>Popup</h2> ...

Utilizing JavaScript to display numerous variables within a text box

After creating an HTML form, I encountered an issue where only one selected item was displayed in the text field. Can anyone help me solve this problem so that multiple names can be printed in the textfield? function myFun(extras) { document.get ...

Including a Script Tag in an Angular 2 Application with a Source Attribute retrieved from a Web API Request

Situation: Within my Angular 2+ application, I am utilizing a web API to retrieve URLs for script tags created by a function called loadScript during the AfterViewInit lifecycle hook. The web API is providing the expected JsonResult data, which I have suc ...

Touch interaction operates differently than mouse movement

Imagine three neighboring divs, div1, div2, and div3. When I click on div1 and then move my mouse to div2, the mousemove event is triggered with div2 as the target. However, on mobile devices, if I tap on div1 (touchstart) and slide my finger to div2, the ...

What is the reason behind getComputedStyle having visibility set to visible?

What is the reason behind getComputedStyle always returning element visibility as visible even when no explicit visibility has been set? For instance: getComputedStyle($('#block1')[0],null).visibility; --- "visible" Meanwhile: $('#block1&a ...

Issue with Navbar collapse button not displaying items on Bootstrap 4.5.0 in combination with Next.js version 9.4.4

I'm currently working on a nextjs demo project where I'm incorporating bootstrap for styling purposes. The initial setup was straightforward as I installed bootstrap using npm and included it in my app.js. import 'bootstrap/dist/css/bootstra ...

ASP not recognizing AngularJS input states

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="Staffing_Tool.Login" %> <!DOCTYPE html> <html> <head runat="server"> <script src="scripts/angular.min.js" type="text/javascript"></scr ...

My HTML files are not getting bundled by Webpack

Despite including dependencies for HTML loaders in my Angular 2 application, webpack is not bundling my HTML files along with the rest of the files it generates. I have tried using both "html-loader" and "html-webpack-plugin," but to no avail. My webpack ...

Can anyone help me identify the issues in my PHP code?

My PHP code doesn't appear to be functioning correctly. Instead of displaying any errors, it simply shows a blank page. Can you identify what I might be doing incorrectly? <?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_ ...

Creating a variety of themes with unique color palettes for Angular Material along with custom-designed components

One of the goals for my app is to have multiple themes, including Angular Material themes, with the ability to define custom colors for specific components and elements that are not part of Angular Material. It's important that when I change a theme, ...

Missing CSS in dynamically loaded content on IE

I have been searching everywhere, but I just can't seem to find a satisfactory answer to this particular question. Whenever I load a few items on the page, they are displayed correctly at first. However, if a user decides to change the language, the ...

Radio buttons failing to transfer any data

I am experiencing an issue with setting values for radio buttons and using the $_POST variable to read the value, but the value being set is empty. <form style="text-align:left;margin-left:80px;" class="form-inline signup" role="form" method="post" act ...

Enhancing the Alignment of a Bootstrap Navbar with CSS

Having trouble centering the listed items (excluding the image and title) in the middle of the navbar. Tried various solutions with no luck! Any suggestions on how to tackle this issue? <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a ...

After sending a post request, the form in HTML with Node.js is returning an undefined response

Upon creating an HTML <form></form> object to capture a username, email, and password, I encountered an issue where the value returned is always undefined when accessing req.body.name or any other field. It seems like the form is not functionin ...

Editing the dimensions of the input in Bootstrap 4

Is there a way to adjust the width of the input and select elements? I want the input element to take up more space while the select element occupies less space. <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel=" ...

Is it possible for ng-model to verify its own value?

Recently, I've been experimenting with Angular and found myself facing a dilemma. Is it possible to apply a different CSS style based on whether the value of ng-model is greater than 0? `<span ng-model="users2" ng-hide="!myVar" ng-class="{'te ...

Eliminating unnecessary whitespace between the bottom of the document and an element

I have a HTML page that when scrolled should limit scroll to the document height. It must not exceed the bottom of an element. Here is a screenshot for better understanding: https://i.stack.imgur.com/RaVg8.jpg The scrolling should be limited after the En ...

"Customize the appearance of your theme by adjusting the background and text colors when making a

Is there a way to dynamically change the style of a webpage based on user selection using CSS in AngularJS? I've searched online, but haven't found a solution that works for me. I have a CSS file with different styles and I want to apply these ...

Is the card-columns class not available in Bootstrap 5.0? Are there any other alternatives provided by Bootstrap besides using CSS media queries and flex column?

While exploring Bootstrap 5.0, I noticed that the card-columns class was missing and there is no mention of it or its alternative in the Bootstrap 5.0 documentation. However, it can still be found in the Bootstrap 4.6 documentation. I understand that usin ...

Animating changes on a webpage using CSS transitions in conjunction with the

Can the border color of a simple line div be changed from top to bottom using GreenSock? .line { position: relative; border: 1px solid #c3ced8; width: 0; height: 50px; display: block; content: ''; z-index: 1; top: -19px; marg ...