"Stylish Sliders/Range Selectors!"
Bootstrap 3.1.0 Snippet by mouse0270

<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="container"> <h2>Range Sliders <small>Only tested in Chrome!</small></h2> <hr/> <div class="row"> <div class="col-xs-6"> <div class="range"> <input type="range" name="range" min="1" max="100" value="50" onchange="range.value=value"> <output id="range">50</output> </div> </div> <div class="col-xs-6"> <div class="range range-primary"> <input type="range" name="range" min="1" max="100" value="50" onchange="rangePrimary.value=value"> <output id="rangePrimary">50</output> </div> </div> </div> <div class="row"> <div class="col-xs-6"> <div class="range range-success"> <input type="range" name="range" min="1" max="100" value="50" onchange="rangeSuccess.value=value"> <output id="rangeSuccess">50</output> </div> </div> <div class="col-xs-6"> <div class="range range-info"> <input type="range" name="range" min="1" max="100" value="50" onchange="rangeInfo.value=value"> <output id="rangeInfo">50</output> </div> </div> </div> <div class="row"> <div class="col-xs-6"> <div class="range range-warning"> <input type="range" name="range" min="1" max="100" value="50" onchange="rangeWarning.value=value"> <output id="rangeWarning">50</output> </div> </div> <div class="col-xs-6"> <div class="range range-danger"> <input type="range" name="range" min="1" max="100" value="50" onchange="rangeDanger.value=value"> <output id="rangeDanger">50</output> </div> </div> </div> </div>
@import url(http://fonts.googleapis.com/css?family=Roboto:400,300); @import url(http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css); body { padding: 70px 0px; } .range { display: table; position: relative; height: 25px; margin-top: 20px; background-color: rgb(245, 245, 245); border-radius: 4px; -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); cursor: pointer; } .range input[type="range"] { -webkit-appearance: none !important; -moz-appearance: none !important; -ms-appearance: none !important; -o-appearance: none !important; appearance: none !important; display: table-cell; width: 100%; background-color: transparent; height: 25px; cursor: pointer; } .range input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none !important; -moz-appearance: none !important; -ms-appearance: none !important; -o-appearance: none !important; appearance: none !important; width: 11px; height: 25px; color: rgb(255, 255, 255); text-align: center; white-space: nowrap; vertical-align: baseline; border-radius: 0px; background-color: rgb(153, 153, 153); } .range input[type="range"]::-moz-slider-thumb { -webkit-appearance: none !important; -moz-appearance: none !important; -ms-appearance: none !important; -o-appearance: none !important; appearance: none !important; width: 11px; height: 25px; color: rgb(255, 255, 255); text-align: center; white-space: nowrap; vertical-align: baseline; border-radius: 0px; background-color: rgb(153, 153, 153); } .range output { display: table-cell; padding: 3px 5px 2px; min-width: 40px; color: rgb(255, 255, 255); background-color: rgb(153, 153, 153); text-align: center; text-decoration: none; border-radius: 4px; border-bottom-left-radius: 0; border-top-left-radius: 0; width: 1%; white-space: nowrap; vertical-align: middle; -webkit-transition: all 0.5s ease; -moz-transition: all 0.5s ease; -o-transition: all 0.5s ease; -ms-transition: all 0.5s ease; transition: all 0.5s ease; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: -moz-none; -o-user-select: none; user-select: none; } .range input[type="range"] { outline: none; } .range.range-primary input[type="range"]::-webkit-slider-thumb { background-color: rgb(66, 139, 202); } .range.range-primary input[type="range"]::-moz-slider-thumb { background-color: rgb(66, 139, 202); } .range.range-primary output { background-color: rgb(66, 139, 202); } .range.range-primary input[type="range"] { outline-color: rgb(66, 139, 202); } .range.range-success input[type="range"]::-webkit-slider-thumb { background-color: rgb(92, 184, 92); } .range.range-success input[type="range"]::-moz-slider-thumb { background-color: rgb(92, 184, 92); } .range.range-success output { background-color: rgb(92, 184, 92); } .range.range-success input[type="range"] { outline-color: rgb(92, 184, 92); } .range.range-info input[type="range"]::-webkit-slider-thumb { background-color: rgb(91, 192, 222); } .range.range-info input[type="range"]::-moz-slider-thumb { background-color: rgb(91, 192, 222); } .range.range-info output { background-color: rgb(91, 192, 222); } .range.range-info input[type="range"] { outline-color: rgb(91, 192, 222); } .range.range-warning input[type="range"]::-webkit-slider-thumb { background-color: rgb(240, 173, 78); } .range.range-warning input[type="range"]::-moz-slider-thumb { background-color: rgb(240, 173, 78); } .range.range-warning output { background-color: rgb(240, 173, 78); } .range.range-warning input[type="range"] { outline-color: rgb(240, 173, 78); } .range.range-danger input[type="range"]::-webkit-slider-thumb { background-color: rgb(217, 83, 79); } .range.range-danger input[type="range"]::-moz-slider-thumb { background-color: rgb(217, 83, 79); } .range.range-danger output { background-color: rgb(217, 83, 79); } .range.range-danger input[type="range"] { outline-color: rgb(217, 83, 79); }

Related: See More


Questions / Comments:

How can i add a label for the slider with <label...>

Ge Si () - 8 years ago - Reply 0


I love them only hated that you used a onchange for it, i'm using these on a website now but wanted the values to change while moving the slider.
So i wrote some custom JQuery to do this:

$('input[name="range"]').on("change mousemove", function() {
$(this).next().html($(this).val() + '%');
});

I will definitely favorite this snippet ! Thanks for building it !!!

WebVerder () - 8 years ago - Reply 0


The classic way to do this is to use "oninput" instead of "onchange".
And yes, I tried it in FF, chrome...

FrankCook () - 7 years ago - Reply 0


Looks even great in old SAFARI 5.1 !

pepperstreet () - 9 years ago - Reply 0


not working in IE latest

John Louie Binas () - 10 years ago - Reply 0


I really didn't think it would work in older versions IE, but I hoped it would have at least worked in IE11

mouse0270 () - 10 years ago - Reply 0


Works with Chrome and Safari on Mac OS X 10.9

Firefox doesn't style the actual ranges though.

cmp () - 10 years ago - Reply 0


Yeah, I tried to add the code, that was supposed to make it support Firefox, but it appears I either did it wrong or Firefox wont let me style it. :(

mouse0270 () - 10 years ago - Reply 0


it’s ::moz-range-thumb there

flying sheep () - 9 years ago - Reply 0


Those are sliders not range selectors. :) But great work!

Alex () - 10 years ago - Reply 0


I called them a range selector due to the fact this is what HTML5 calls them. Take a look at the html, the type is "range". I do understand what you mean though.

mouse0270 () - 10 years ago - Reply 0