range slider style : demo 17

0
0
0

HTML

                        
0

CSS

                        :root{
                            --white: #fff;
                            --dark: #ddd;
                            --main-color: #8e44ad;
                        }
                        .range-slider{ margin: 30px 0 0 0; }
                        .range-slider input[type="range"]{
                            background: var(--white);
                            width: calc(100% - (85px));
                            height: 29px;
                            border: 1px solid var(--dark);
                            border-radius: 5px;
                            outline: none;
                            float: left;
                            -webkit-appearance: none;
                            position: relative;
                        }
                        .range-slider input[type="range"]::-webkit-slider-thumb{
                            background: var(--main-color);
                            width: 7px;
                            height: 30px;
                            border-radius: 20px;
                            cursor: pointer;
                            transition: all 0.15s ease-in-out 0s;
                            -webkit-appearance: none;
                            appearance: none;
                        }
                        .range-slider input[type="range"]::-webkit-slider-thumb:hover,
                        .range-slider input[type="range"]:active::-webkit-slider-thumb{
                            width: 9px;
                            box-shadow: 0 0 2px var(--white) inset, 0 0 1px var(--dark);
                        }
                        .range-slider input[type="range"]::-moz-range-thumb{
                            background: var(--main-color);
                            width: 7px;
                            height: 30px;
                            cursor: pointer;
                            border: none;
                            border-radius: 20px;
                            transition: all 0.15s ease-in-out 0s;
                        }
                        .range-slider input[type="range"]::-moz-range-thumb:hover,
                        .range-slider input[type="range"]:active::-moz-range-thumb{
                            width: 9px;
                            box-shadow: 0 0 3px var(--white) inset, 0 0 1px var(--dark);
                        }
                        .range-slider .range-value{
                            color: var(--white);
                            background: var(--main-color);
                            font-size: 18px;
                            font-weight: 600;
                            text-align: center;
                            line-height: 45px;
                            width: 45px;
                            height: 45px;
                            margin-left: 10px;
                            border-radius: 50%;
                            display: inline-block;
                            position: relative;
                            top: -9px;
                        }
                        ::-moz-range-track{
                            background: transparent;
                            border: 0;
                        }
                    

JavaScript

(Range Slider depend on jQuery.)
                        

                        $(document).ready(function(){
                            var rangeSlider = function(){
                                var slider = $('.range-slider'),
                                    range = $('.range-slider input[type="range"]'),
                                    value = $('.range-value');
                                slider.each(function(){
                                    value.each(function(){
                                        var value = $(this).prev().attr('value');
                                        $(this).html(value);
                                    });
                                    range.on('input', function(){
                                        $(this).next(value).html(this.value);
                                    });
                                });
                            };
                            rangeSlider();
                        });
                    
License Terms