gpt4 book ai didi

javascript - 增加可点击区域的输入范围

转载 作者:太空宇宙 更新时间:2023-11-04 15:55:29 26 4
gpt4 key购买 nike

我正在尝试使用窄跟踪器和小拇指编写输入范围,但可点击区域比跟踪器更宽。

<div class="slider-wrapper">
<input type="range" orient="vertical" class="volume-slider"/>
</div>

例如,我有一个用于输入范围的 div.slider-wrapper 包装器,当我在包装器内部单击时,输入值会发生变化。

jsfiddle

我检查了rangeslider.jsjquery ui slider , 但没有找到解决方案。

.slider-wrapper{
background: rgba(0, 0, 0, 0.8);
width: 40px;
height: 100px;
position: relative;
left: 1px;
}

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: 80px;

transform: rotate(270deg);

position: relative;
left: -22px;
top: 37px;
}
input[type=range]::-webkit-slider-runnable-track {
width: 80px;
height: 2px;
background: #61b4f7;
border: none;
/*border-radius: 2px;*/
}

input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none;
border: none;
height: 10px;
width: 10px;
border-radius: 50%;
background: #61b4f7;
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: 80px;
height: 2px;
background: #61b4f7;
border: none;
/* border-radius: 3px; */
}
input[type=range]::-moz-range-thumb {
border: none;
height: 10px;
width: 10px;
border-radius: 50%;
background: #61b4f7;
}

/*hide the outline behind the border*/
input[type=range]:-moz-focusring{
outline: 1px solid white;
outline-offset: -1px;
}

input[type=range]::-ms-track {
width: 80px;
height: 2px;

/*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: #61b4f7;
border-radius: 10px;
}
input[type=range]::-ms-thumb {
border: none;
height: 10px;
width: 10px;
border-radius: 50%;
background: #61b4f7;
}
input[type=range]:focus::-ms-fill-lower {
background: #888;
}
input[type=range]:focus::-ms-fill-upper {
background: #ccc;
}
<div class="slider-wrapper">
<input type="range" orient="vertical" class="volume-slider"/>
</div>

最佳答案

向范围元素添加填充将增加可点击空间。然后,您可以在元素上放置透明背景:

.slider-wrapper{
background: rgba(0, 0, 0, 0.8);
width: 40px;
height: 100px;
position: relative;
left: 1px;
}

input[type=range] {
padding: 19px 10px;
background-color: transparent;

/*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: 80px;

transform: rotate(270deg);

position: relative;
left: -32px;
top: 28px;
}
input[type=range]::-webkit-slider-runnable-track {
width: 80px;
height: 2px;
background: #61b4f7;
border: none;
/*border-radius: 2px;*/
}

input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none;
border: none;
height: 10px;
width: 10px;
border-radius: 50%;
background: #61b4f7;
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: 80px;
height: 2px;
background: #61b4f7;
border: none;
/* border-radius: 3px; */
}
input[type=range]::-moz-range-thumb {
border: none;
height: 10px;
width: 10px;
border-radius: 50%;
background: #61b4f7;
}

/*hide the outline behind the border*/
input[type=range]:-moz-focusring{
outline: 1px solid white;
outline-offset: -1px;
}

input[type=range]::-ms-track {
width: 80px;
height: 2px;

/*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: #61b4f7;
border-radius: 10px;
}
input[type=range]::-ms-thumb {
border: none;
height: 10px;
width: 10px;
border-radius: 50%;
background: #61b4f7;
}
input[type=range]:focus::-ms-fill-lower {
background: #888;
}
input[type=range]:focus::-ms-fill-upper {
background: #ccc;
}
<div class="slider-wrapper">
<input type="range" orient="vertical" class="volume-slider"/>
</div>

关于javascript - 增加可点击区域的输入范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46091938/

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