gpt4 book ai didi

javascript - 范围 slider 开始和结束处的圆圈

转载 作者:太空宇宙 更新时间:2023-11-04 09:06:57 24 4
gpt4 key购买 nike

我想制作一个带有一些设计的范围 slider 。我不知道如何风格化输入。 http://prntscr.com/ebyoev像这个我想做的是,我不知道如何在范围 slider 的开始和结束处实现圆圈以及如何对当前圆圈范围进行样式化

https://jsfiddle.net/agghvm9t/这是 fiddle

这就是我的进步

<div class="range-slider">
<input class="range-slider__range" type="range" value="100" min="0" max="500">
</div>

这是我的CSS

 *, *:before, *:after {
box-sizing: border-box;
}

body {
font-family: sans-serif;
padding: 60px 20px;
}
@media (min-width: 600px) {
body {
padding: 60px;
}
}

.range-slider {
margin: 60px 0 0 0%;
}

.range-slider {
width: 100%;
}

.range-slider__range {
-webkit-appearance: none;
width: calc(100% - (73px));
height: 10px;
border-radius: 5px;
background: #d7dcdf;
outline: none;
padding: 0;
margin: 0;
}
.range-slider__range::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 20px;
height: 20px;
border-radius: 50%;
background: #2c3e50;
cursor: pointer;
-webkit-transition: background .15s ease-in-out;
transition: background .15s ease-in-out;
}
.range-slider__range::-webkit-slider-thumb:hover {
background: #1abc9c;
}
.range-slider__range:active::-webkit-slider-thumb {
background: #1abc9c;
}
.range-slider__range::-moz-range-thumb {
width: 20px;
height: 20px;
border: 0;
border-radius: 50%;
background: #2c3e50;
cursor: pointer;
-webkit-transition: background .15s ease-in-out;
transition: background .15s ease-in-out;
}
.range-slider__range::-moz-range-thumb:hover {
background: #1abc9c;
}
.range-slider__range:active::-moz-range-thumb {
background: #1abc9c;
}

.range-slider__value {
display: inline-block;
position: relative;
width: 60px;
color: #fff;
line-height: 20px;
text-align: center;
border-radius: 3px;
background: #2c3e50;
padding: 5px 10px;
margin-left: 8px;
}
.range-slider__value:after {
position: absolute;
top: 8px;
left: -7px;
width: 0;
height: 0;
border-top: 7px solid transparent;
border-right: 7px solid #2c3e50;
border-bottom: 7px solid transparent;
content: '';
}

::-moz-range-track {
background: #d7dcdf;
border: 0;
}

input::-moz-focus-inner,
input::-moz-focus-outer {
border: 0;
}

这是我的jquery

    var rangeSlider = function(){
var slider = $('.range-slider'),
range = $('.range-slider__range'),
value = $('.range-slider__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();

最佳答案

我会使用伪元素来解决这个问题。你可以有一个 :before 和一个 :after 伪元素,因为你只需要两个 - 一个在开头,一个在结尾,它可能会起作用:

.range-slider {
position:relative;
}
.range-slider:before {
content: "";
position: absolute;
left: 0;
background-image: url("circle-image");
width: 25px;
height: 25px;
}
.range-slider:after {
content: "";
position: absolute;
right: 0;
background-image: url("circle-image");
width: 25px;
height: 25px;
}

要设置滑动圆圈的样式,您可以尝试这样的操作:

.range-slider__range::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 36px;
height: 36px;
border-radius: 50%;
background: orange;
cursor: pointer;
-webkit-transition: background .15s ease-in-out;
transition: background .15s ease-in-out;
border: 1px solid orange;
box-shadow: inset 0 0 0 6px #fff;
}

关于javascript - 范围 slider 开始和结束处的圆圈,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42390789/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com