Progress bar

by namlth

HTML

<script src="//code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<link rel="stylesheet" href="//stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="//stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script>
<div id="testId" class="d-flex align-items-center justify-content-between">
  <div class="div-side"></div>
  <div class="progress d-flex align-items-center justify-content-between">
    <div id="step1" class="step active">
      <div class="step-icon">
        <i class="far fa-square"></i>
      </div>
    </div>
    <div id="step2" class="step active">
      <div class="step-icon">
        <i class="far fa-square"></i>
      </div>
    </div>
    <div id="step3" class="step active">
      <div class="step-icon">
        <i class="far fa-square"></i>
      </div>
    </div>
    <div id="step4" class="step">
      <div class="step-icon">
        <i class="far fa-square"></i>
      </div>
    </div>
    <div id="step5" class="step">
      <div class="step-icon">
        <i class="far fa-square"></i>
      </div>
    </div>
  </div>
  <div class="div-side"></div>
</div>

SCSS

.progress{
  width: 100%;
  height: 100px;
  background: lightblue;
}

.div-side{
  width: 100px;
  height: 100px;
  background: lightgreen;
}

.horizontal-line{
  height: 10px;
  width: 100%;
  //border-bottom: 10px solid red;
  border-top-left-radius: 60px;
  border-bottom-left-radius: 60px;
  border-top-right-radius: 60px;
  border-bottom-right-radius: 60px;
  padding-left: 10px;
  padding-right: 10px;
  background: red;
  position: absolute;
}

.step-wrapper{
  min-width: 25%;
  background-color: lightyellow;
  display: flex;
  align-items: center;
  justify-content: center;
  list-style: none;
}

.step {
  min-width: 25%;
  background-color: lightyellow;
  text-align: center;
  position: relative;
  display: flex;
  justify-content: center;
    list-style: none;

}

.step.active{
  //min-width: 100%;
  background-color: black;
}

.step.active:before,
.step.active:after{
  content: "";
  //width: 500%;
  top: 50%;
  z-index: 1;
  border: 2px solid white;
  position: absolute;
  //-webkit-transition: width 2s, height 4s; /* For Safari 3.1 to 6.0 */
  //transition: width 2s, height 4s;
}

.step.active:before {
  left: 0;
  right: 50%;
}

.step.active:after {
  left: 50%;
  right: 0;
}

.step.active:first-of-type:before {
  border: none;
}

.step.active:last-of-type:after {
  border: none;
}

.step-icon{
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: red;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;

  i {
    width: initial;
    color: darkblue;
    font-size: 1.5rem;
  }
}

JavaScript

alert($("div.active:nth-last-of-type(3)").attr("id"));