"Bootstrap 5 Process Steps Responsive"
Bootstrap 4.1.1 Snippet by ozki

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/css/bootstrap.min.css"
integrity="sha384-r4NyP46KrjDleawBgD5tp8Y7UzmLA05oM1iAEQ17CSuDqnUK2+k9luXQOfXJCJ4I" crossorigin="anonymous">
<h1 class="text-center">Bootstrap 5 Process Steps</h1>
<a href="https://youtu.be/EaW1mPg7FWA">You can watch youtube video explaining how it's done!</a>
<section>
<div class="container">
<div class="accordion" id="accordionExample">
<div class="steps">
<progress id="progress" value=0 max=100 ></progress>
<div class="step-item">
<button class="step-button text-center" type="button" data-toggle="collapse"
data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
1
</button>
<div class="step-title">
First Step
</div>
</div>
<div class="step-item">
<button class="step-button text-center collapsed" type="button" data-toggle="collapse"
data-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
2
</button>
<div class="step-title">
Second Step
</div>
</div>
<div class="step-item">
<button class="step-button text-center collapsed" type="button" data-toggle="collapse"
data-target="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
3
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
:root {
--prm-color: #0381ff;
--prm-gray: #b1b1b1;
}
body {
height: 100vh;
display: flex;
align-items: center;
justify-content: space-evenly;
flex-direction:column;
}
section{
width:100%;
}
.steps {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 2rem;
position: relative;
}
.step-button {
width: 50px;
height: 50px;
border-radius: 50%;
border: none;
background-color: var(--prm-gray);
transition: .4s;
}
.step-button[aria-expanded="true"] {
width: 60px;
height: 60px;
background-color: var(--prm-color);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
const stepButtons = document.querySelectorAll('.step-button');
const progress = document.querySelector('#progress');
Array.from(stepButtons).forEach((button,index) => {
button.addEventListener('click', () => {
progress.setAttribute('value', index * 100 /(stepButtons.length - 1) );//there are 3 buttons. 2 spaces.
stepButtons.forEach((item, secindex)=>{
if(index > secindex){
item.classList.add('done');
}
if(index < secindex){
item.classList.remove('done');
}
})
})
})
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments: