Sunday 3 March 2019

Switch button using pure css with custom text

////////////////////// css



.switch-btn {
  positionrelative;
  displayinline-block;
  width90px;
  height34px;
}

.switch-btn .switch input {display:none;}

.switch-btn .slider {
  positionabsolute;
  cursorpointer;
  top0;
  left0;
  right0;
  bottom0;
  background-color#ca2222;
  -webkit-transition.4s;
  transition.4s;
}

.switch-btn .slider:before {
  positionabsolute;
  content"";
  height26px;
  width26px;
  left4px;
  bottom4px;
  background-colorwhite;
  -webkit-transition.4s;
  transition.4s;
}

.switch-btn input:checked + .slider {
  background-color#2ab934;
}

.switch-btn input:focus + .slider {
  box-shadow0 0 1px #2196F3;
}

.switch-btn input:checked + .slider:before {
  -webkit-transformtranslateX(55px);
  -ms-transformtranslateX(55px);
  transformtranslateX(55px);
}

/*------ ADDED CSS ---------*/
.switch-btn .on
{
  displaynone;
}

.switch-btn .on.off
{
  colorwhite;
  positionabsolute;
  transformtranslate(-50%,-50%);
  top50%;
  left50%;
  font-size10px;
  font-familyVerdana, sans-serif;
}

.switch-btn input:checked+ .slider .on
{displayblock;}

.switch-btn input:checked + .slider .off
{displaynone;}

.switch-btn .slider.round {
  border-radius34px;
}

..switch-btn slider.round:before {
  border-radius50%;}

///////////////////////// html


<label class="switch-btn">
    <!--HTML -->
  <input type="checkbox" id="Chk_toggle">
   <div class="slider round">
      <!--Custom text -->
        <span class="on">ON</span>
        <span class="off">OFF</span>
    </div>
</label>



/////////////////   Result




No comments:

Post a Comment

Excel Sort values in ascending order using function TEXTJOIN

 Excel ::  Text ::  1,3,5,2,9,5,11 Result :: 1,2,3,5,5,9,11 Formula ::     TEXTJOIN ( ",",1,SORT(MID(SUBSTITUTE( A1 ,","...