Reputation: 131
I have some code in which I style a range type input field, but it seems as though this style is not compatible with IE11.
try.html
<div class="footer">
<div class="row justify-content-center">
<div class="container">
<input class="range" type="range" min="0" max="100">
</div>
</div>
</div>
style.css
.slider{
-webkit-appearance: none;
width: 100%;
padding: 0;
height: 3px;
opacity: 1;
background: #d3d3d3;
}
.slider::-webkit-slider-thumb{
-webkit-appearance: none;
appearance: none;
border:3px solid #6452d6;
border-radius: 25px;
background-color: white;
width: 55px;
height: 20px;
}
I have managed to display the required design in Chrome, but this CSS does not seem to work with IE11. How can I make this display properly in IE11?
Upvotes: 2
Views: 148
Reputation: 917
Please read my code carefully, You need to add MS filler.
body {
padding: 30px;
}
input[type=range] {
/*removes default webkit styles*/
-webkit-appearance: none;
/*fix for FF unable to apply focus style bug */
border: 1px solid white;
/*required for proper track sizing in FF*/
width: 300px;
}
input[type=range]::-webkit-slider-runnable-track {
width: 300px;
height: 5px;
background: #ddd;
border: none;
border-radius: 3px;
}
input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none;
border: none;
height: 16px;
width: 16px;
border-radius: 50%;
background: goldenrod;
margin-top: -4px;
}
input[type=range]:focus {
outline: none;
}
input[type=range]:focus::-webkit-slider-runnable-track {
background: #ccc;
}
input[type=range]::-moz-range-track {
width: 300px;
height: 5px;
background: #ddd;
border: none;
border-radius: 3px;
}
input[type=range]::-moz-range-thumb {
border: none;
height: 16px;
width: 16px;
border-radius: 50%;
background: goldenrod;
}
/*hide the outline behind the border*/
input[type=range]:-moz-focusring{
outline: 1px solid white;
outline-offset: -1px;
}
input[type=range]::-ms-track {
width: 300px;
height: 5px;
/*remove bg colour from the track, we'll use ms-fill-lower and ms-fill-upper instead */
background: transparent;
/*leave room for the larger thumb to overflow with a transparent border */
border-color: transparent;
border-width: 6px 0;
/*remove default tick marks*/
color: transparent;
}
input[type=range]::-ms-fill-lower {
background: #777;
border-radius: 10px;
}
input[type=range]::-ms-fill-upper {
background: #ddd;
border-radius: 10px;
}
input[type=range]::-ms-thumb {
border: none;
height: 16px;
width: 16px;
border-radius: 50%;
background: goldenrod;
}
input[type=range]:focus::-ms-fill-lower {
background: #888;
}
input[type=range]:focus::-ms-fill-upper {
background: #ccc;
}
<div class="footer">
<div class="row justify-content-center">
<div class="container">
<input class="range" type="range" min="0" max="100">
</div>
</div>
</div>
You need add MS fillers like this:
input[type=range]::-ms-track
input[type=range]::-ms-thumb
input[type=range]::-ms-fill-upper
input[type=range]::-ms-fill-lower
For more information you can go here JSfiddle
Hope this will help you. :)
Upvotes: 2