Skip to content

Instantly share code, notes, and snippets.

@jgthms
Created February 20, 2015 12:25
Show Gist options
  • Save jgthms/5173ea9aa2e19de0c89d to your computer and use it in GitHub Desktop.
Save jgthms/5173ea9aa2e19de0c89d to your computer and use it in GitHub Desktop.
iOS Switch with HTML input range
/* Tricky stuff */
.range{ height: 30px; position: relative; width: 50px;}
.range input[type=range] {
-webkit-appearance: none;
outline: none;
width: 100%;
}
.range input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none;
}
.range input[type=range]:focus {
outline: none;
}
.range input[type=range]::-ms-track {
background: transparent;
border-color: transparent;
color: transparent;
cursor: pointer;
width: 100%;
}
/* Thumb */
.range input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none;
background: #ffffff;
border: 1px solid #b3b3b3;
box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.1);
border-radius: 15px;
cursor: pointer;
height: 30px;
margin-top: 0;
width: 30px;
}
.range input[type=range]::-moz-range-thumb {
background: #ffffff;
border: 1px solid #b3b3b3;
box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.1);
border-radius: 15px;
cursor: pointer;
height: 30px;
width: 30px;
}
.range input[type=range]::-ms-thumb {
background: #ffffff;
border: 1px solid #b3b3b3;
box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.1);
border-radius: 15px;
cursor: pointer;
height: 30px;
width: 30px;
}
/* Track */
.range input[type=range]::-webkit-slider-runnable-track {
background: #e6e6e6;
border: none;
border-radius: 15px;
box-shadow: inset 0 0 0 0px rgba(0,0,0,0.4);
cursor: pointer;
height: 30px;
outline: none;
width: 100%;
}
.range input[type=range]:focus::-webkit-slider-runnable-track {
background: #e6e6e6;
outline: none;
}
.range input[type=range]::-moz-range-track {
background: #e6e6e6;
border: none;
border-radius: 15px;
box-shadow: inset 0 0 0 0px rgba(0,0,0,0.4);
cursor: pointer;
height: 30px;
outline: none;
width: 100%;
}
.range input[type=range]::-ms-track {
background: transparent;
border-color: transparent;
border-width: 16px 0;
color: transparent;
cursor: pointer;
height: 30px;
outline: none;
width: 100%;
}
.range input[type=range]::-ms-fill-lower {
border: none;
background: #e6e6e6;
box-shadow: inset 0 0 0 0px rgba(0,0,0,0.4);
border-radius: 2.6px;
}
.range input[type=range]:focus::-ms-fill-lower {
background: #e6e6e6;
outline: none;
}
.range input[type=range]::-ms-fill-upper {
background: #e6e6e6;
box-shadow: inset 0 0 0 0px rgba(0,0,0,0.4);
border-radius: 2.6px;
}
.range input[type=range]:focus::-ms-fill-upper {
background: #e6e6e6;
outline: none;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment