Search code examples
javascripthtmlcssline

Anyone have easy way to create this using css and html?


enter image description here

I have done this with below code, But I this it is a difficult way to do this anyone have easy way for create this with css and html.

.fline {
  width: 2px;
  background-color: black;
  height: 10px;
  margin-left: 30%;
  margin-top: -9px;
}

.fline1 {
  width: 2px;
  background-color: black;
  height: 10px;
  margin-left: 60%;
  margin-top: -10px;
}

.fline2 {
  width: 2px;
  background-color: black;
  height: 10px;
  margin-left: 88.2%;
  margin-top: -11px;
}
<hr style="width: 300px;margin-left: 30%;color:black">
<div class="fline"></div>
<div class="fline1"></div>
<div class="fline2"></div>


Solution

  • This one is the right answer to this question

    .scale-container {
      width: 300px;
    }
    
    .scale {
      width: 296px;
      height: 20px;
      border: 2px solid black;
      border-bottom: none;
    }
    
    .scale>div {
      width: 50%;
      height: 20px;
      border-right: 2px solid black;
    }
    
    .label-container {
      width: 100%;
      display: flex;
      justify-content: space-between;
    }
    <div class="scale-container">
      <div class="scale">
        <div></div>
      </div>
      <div class="label-container">
        <div>Low</div>
        <div>Average</div>
        <div>High</div>
      </div>
    </div>