gpt4 book ai didi

html 输入范围拇指平滑移动

转载 作者:太空狗 更新时间:2023-10-29 16:04:59 26 4
gpt4 key购买 nike

我有一个 HTML 输入范围设置,其中包含一堆 CSS 外观更改,我想知道是否有任何方法可以使其从任何位置平滑地更改到用户更改的位置?

input[type=range] {
-webkit-appearance: none;
width: 100%;
height: 20px;
border-radius: 5px;
border: 1px solid;
background: none;
box-shadow: 0px 0px 8px 0px #555, 0px 0px 25px 0px #555 inset;
transition: 0.4s all ease-out;
outline: none;
}

input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none;
width: 30px;
height: 30px;
background-color: #CCC;
border: solid 1px #333;
border-radius: 4px;
box-shadow: 0px 0px 8px 0px #555, 0px 0px 25px 0px #555 inset;
cursor: pointer;
transition: 0.4s all ease-out;
}

input[type=range]:hover {
background: rgba(255, 255, 255, 0.2);
box-shadow: 0px 0px 13px 0px #444, 0px 0px 20px 0px #444 inset;
}

input[type=range]:hover::-webkit-slider-thumb {
border: solid 1px #444;
box-shadow: 0px 0px 15px 0px #444, 0px 0px 20px 0px #444 inset;
}

input[type=range]:focus {
background: rgba(255, 255, 255, 0.4);
box-shadow: 0px 0px 18px 0px #333, 0px 0px 15px 0px #333 inset;
}

input[type=range]:focus::-webkit-slider-thumb {
border: solid 1px #333;
box-shadow: 0px 0px 22px 0px #333, 0px 0px 15px 0px #333 inset;
}
<input type="range" id="brightness_slider" value="90" step="1" min="30" max="100">

最佳答案

这些是影响平滑度的东西:

  1. 横幅的宽度
  2. 最小/最大范围
  3. 步长

如果你有:

  1. 1000px 宽范围输入
  2. 0 - 1000 范围
  3. 步长为 1

每一步只有1px,而且会很流畅。

如果你有:

  1. 1000px 宽范围输入
  2. 0 -100 范围
  3. 步长为 25

它会在允许值之间快速移动,看起来不太流畅。

这实际上是您的步长和范围之间相互作用的一个特征,并向用户提供有关可接受的值的有用反馈。

关于html 输入范围拇指平滑移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40441445/

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