Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to set line length in Bootstrap?

I have the following HTML:

.line {
  width: 100%;
  height: 14px;
  border-bottom: 1px solid lightgrey;
  position: absolute;
}

.circle {
  height: 24px;
  width: 24px;
  background-color: lightgrey;
  border-radius: 50%;
  display: inline-block;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="align-text-center">
  <div class="row justify-content-center">
    <div class="col-sm-1 text-center">
      <div id="step-1" class="circle">
        <div class="line"></div>
      </div>
      <p>Step 1</p>
    </div>
    <div class="col-sm-1 text-center">
      <div id="step-1" class="circle">
        <div class="line"></div>
      </div>
      <p>Step 2</p>
    </div>
    <div class="col-sm-1 text-center">
      <div id="step-1" class="circle">
        <div class="line"></div>
      </div>
      <p>Step 3</p>
    </div>
  </div>
</div>

This is currently the result:

Steps

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Not part of the code above, but I do know which step is the first and last.

How can I make sure that the line of the last step doesn’t extend outside the circle?

>Solution :

Targeting the div with an ID or class would be better, but with your existing markup you could use .row.justify-content-center div:last-child > div > div to select the last <div class="line"></div> and set the display to none.

.line {
  width: 100%;
  height: 14px;
  border-bottom: 1px solid lightgrey;
  position: absolute;
}

.circle {
  height: 24px;
  width: 24px;
  background-color: lightgrey;
  border-radius: 50%;
  display: inline-block;
}

.row.justify-content-center div:last-child>div>div {
  display: none;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="align-text-center">
  <div class="row justify-content-center">
    <div class="col-sm-1 text-center">
      <div id="step-1" class="circle">
        <div class="line"></div>
      </div>
      <p>Step 1</p>
    </div>
    <div class="col-sm-1 text-center">
      <div id="step-1" class="circle">
        <div class="line"></div>
      </div>
      <p>Step 2</p>
    </div>
    <div class="col-sm-1 text-center">
      <div id="step-1" class="circle">
        <div class="line"></div>
      </div>
      <p>Step 3</p>
    </div>
  </div>
</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading