<form class="c-bmi">
  <label class="c-bmi__label"><strong>Height</strong>
    <input class="c-bmi__range" type="range" name="h" min="150" max="230" step="0.5" value="180" />
    <output name="ho"><output>
  </label>
  <label class="c-bmi__label"><strong>Weight</strong>
    <input class="c-bmi__range" type="range" name="w" min="35" max="200" step="0.1" value="75" />
    <output name="wo">75</output>
  </label>
  <div class="c-bmi__result">Your BMI Is: <output name="r"></output></div>
  <div class="c-bmi__groups" readonly>
    <input type="radio" id="bmi-g0" name="g" />
    <label for="bmi-g0">Underweight</label>
    <div class="c-bmi__group-text">The WHO regards a BMI of less than 18.5 as underweight and may indicate malnutrition, an eating disorder, or other health problems.</div>
    <input type="radio" id="bmi-g1" name="g" checked />
    <label for="bmi-g1">Normal</label>
    <div class="c-bmi__group-text">A BMI between 18.5 and 25 is considered normal and healthy. </div>
    <input type="radio" id="bmi-g2" name="g" />
    <label for="bmi-g2">Pre-obesity</label>
    <div class="c-bmi__group-text">People who fall into this category may be at risk of developing obesity.<br />This was earlier classified as "overweight".</div>
    <input type="radio" id="bmi-g3" name="g" />
    <label for="bmi-g3">Obese I</label>
    <div class="c-bmi__group-text">People who have BMI equal or over 30 may have obesity, which is defined as an abnormal or excessive accumulation of fat that may harm health.</div>
    <input type="radio" id="bmi-g4" name="g" />
    <label for="bmi-g4">Obese II</label>
    <div class="c-bmi__group-text">People who have BMI equal or over 30 may have obesity, which is defined as an abnormal or excessive accumulation of fat that may harm health.</div>
    <input type="radio" id="bmi-g5" name="g" />
    <label for="bmi-g5">Obese III</label>
    <div class="c-bmi__group-text">People who have BMI equal or over 30 may have obesity, which is defined as an abnormal or excessive accumulation of fat that may harm health.</div>
  </div>
</form>
.c-bmi {
  background-color: hsl(211, 20%, 92%);
  border-radius: .25rem;
  box-sizing: border-box;
  font-family: ui-sans-serif, system-ui, sans-serif;
  padding: 1rem;
  max-width: 40rem;
  width: 100%;
}
.c-bmi fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}
.c-bmi__group-text {
  display: none;
  font-size: small;
  order: 2;
  padding: 1rem 0;
  text-align: left;
  width: 100%;
}
.c-bmi__groups {
  border: 0;
  flex-wrap: wrap;
  font-size: x-small;
  padding: 0;
  text-align: center;
  width: 100%;
}
.c-bmi__groups label {
  display: block;
  padding: .5rem;
  position: relative;
}

[for="bmi-g0"] { background-color: #4691e2; }
[for="bmi-g1"] { background-color: #0cb764; }
[for="bmi-g2"] { background-color: #febf18; }
[for="bmi-g3"] { background-color: #fc8711; }
[for="bmi-g4"] { background-color: #ff6455; }
[for="bmi-g5"] { background-color: #cc1100; color: #fff; }

.c-bmi__groups input:checked + label::before {
  background-color: #fff;
  clip-path: polygon(0% 0%,0% 100%,75.00% 50.00%);
  content: '';
  display: inline-block;
  height: 1rem;
  left: 0.5rem;
  position: absolute;
  top: 0.35rem;
  width: 1rem;
}
.c-bmi__groups input:checked + label + div {
  display: block;
  flex: 0 0 100%;
}
.c-bmi__label {
  display: block;
  font-size: medium;
  margin: 0 0 1rem 0;
  position: relative;
}
.c-bmi__label output {
  position: absolute;
  right: 0;
  top: 0;
}
.c-bmi__range {
  -webkit-appearance: none;
  appearance: none;
  background-color: transparent;
  outline: none;
  width: 100%;
}
.c-bmi__range::-webkit-slider-runnable-track {
  background-image: linear-gradient(to bottom, transparent 45%, lightslategray 45%, lightslategray 55%, transparent 55%);
}
.c-bmi__range::-moz-range-track {
  background-image: linear-gradient(to bottom, transparent 45%, lightslategray 45%, lightslategray 55%, transparent 55%);
}
.c-bmi__range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  background-color: hsl(225,100%,20%);
  border-radius: 50%;
  height: 2rem;
  width: 2rem;
}
.c-bmi__range::-moz-range-thumb {
  appearance: none;
  background-color: hsl(225,100%,20%);
  border-radius: 50%;
  height: 2rem;
  width: 2rem;
}
.c-bmi__range:focus::-webkit-slider-thumb {
  background-color: hsl(225,30%,60%);
  box-shadow: inset 0 0 0 0.25rem hsl(225,100%,20%);
}
.c-bmi__range:focus::-moz-range-thumb {
  background-color: hsl(225,30%,60%);
  box-shadow: inset 0 0 0 0.25rem hsl(225,100%,20%);
}
.c-bmi__result {
  display: block;
  font-size: 200%;
  margin-bottom: 1.5rem;
  text-align: right;
}
.c-bmi [type="radio"] { display: none; }

/* RWD */
@media (min-width: 600px) {
  .c-bmi__groups { display: flex; }
  .c-bmi__groups input:checked + label::before {
    background-color: inherit;
    clip-path: polygon(0% 0%,100% 0%,50% 100%);
    left: 50%;
    top: -1rem;
    transform: translateX(-50%);
    width: 1.5rem;
  }
  .c-bmi__groups label { flex: 1; }
  [for="bmi-g0"] { border-radius: .25rem 0 0 .25rem; }
  [for="bmi-g5"] { border-radius: 0 .25rem .25rem 0; }
}

/* For this demo */
body { max-width: 40rem; margin: 1rem auto; }
function B(){const e=this.h.valueAsNumber,t=this.w.valueAsNumber,i=parseFloat(t/(e/100)**2).toFixed(2),h=[[0,18.49],[18.5,24.99],[25,29.99],[30,34.99],[35,39.99],[40,100]].findIndex(e=>e[0]<=i&&i<e[1]);let o=(.393700787*e).toFixed(0);this.ho.value=`${e} cm / ${Math.floor(o/12)}' ${o%=12}"`,this.wo.value=`${t} kg / ${(2.2046*t).toFixed(2)} lb`,this.g[h].checked=!0,this.r.value=i}
const bmi = document.querySelector('.c-bmi')
bmi.addEventListener('input', B);
bmi.dispatchEvent(new Event('input'));

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.