Within the following script, I am emulating a stepper using row
and col.
It appears satisfactory.
Nevertheless, when the page is viewed on wide screens (such as lg
and xl
), the spacing between the steps is excessive. Essentially, the stepper occupies the entire width of its container. I desire for it to occupy 60%, 80%, or some other specified width instead. I can make use of media breakpoints to regulate this.
On wider screens, I would like the steps to be positioned closer together. Additionally, there is an issue with the line between steps 3 and 4 as it breaks prematurely.
Would transitioning from row
and col
to flex
rectify my issue? If so, what is the proper approach to achieve this? Or is there an alternative solution available?
Note: Rendering on smaller screens poses no problem because I conceal the step text in such cases.
.row.justify-content-center div:last-child > div > div {
display: none;
}
.line {
width: 100%;
height: 9px;
margin-left: 16px;
border-bottom: 2px solid lightgrey;
position: absolute;
display: block;
pointer-events: none;
cursor: default;
}
.circle {
height: 16px;
width: 16px;
background-color: lightgrey;
border-radius: 50%;
display: inline-block;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/4.6.2/css/bootstrap.min.css">
<div class="card cw-480">
<div class="card-body">
<div class="align-text-center">
<div class="row justify-content-center">
<div class="col text-center">
<div id="step-1" class="circle">
<div class="line"></div>
</div>
<p>Step 1</p>
</div>
<div class="col text-center">
<div id="step-2" class="circle">
<div class="line"></div>
</div>
<p>Step 2</p>
</div>
<div class="col text-center">
<div id="step-3" class="circle">
<div class="line"></div>
</div>
<p>Step 3</p>
</div>
<div class="col text-center">
<div id="step-4" class="circle">
<div class="line"></div>
</div>
<p>Longlonglongstep 4</p>
</div>
<div class="col text-center">
<div id="step-5" class="circle">
<div class="line"></div>
</div>
<p>Step 5</p>
</div>
<div class="col text-center">
<div id="step-6" class="circle">
<div class="line"></div>
</div>
<p>Step 6</p>
</div>
</div>
</div>
</div>
</div>