Html 范围输入类型的步长参数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8369252/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 11:48:39  来源:igfitidea点击:

Step parameter for input type of range

htmlinputrange

提问by Joe Longstreet

Is it possible to specify a decimal for a step parameter within the range element? According to a few articles I've read, including one on Nettuts, this should be possible. This does not appear to be working in any browsers. I've tried Chrome, Safari, and mobile Safari. Am I misunderstanding simple here, or is this just not supported quite yet?

是否可以在范围元素内为步骤参数指定小数?根据我读过的几篇文章,包括一篇关于Nettuts 的文章,这应该是可能的。这似乎不适用于任何浏览器。我尝试过 Chrome、Safari 和移动版 Safari。我在这里误解很简单,还是还没有完全支持?

 <input id='something' type='range' min='0' max='20' step='.25' value='5' />

回答by aWebDeveloper

http://jsfiddle.net/Df57B/

http://jsfiddle.net/Df57B/

Check out this demo it is possible to give steps in decimal.

看看这个演示,可以给出十进制的步骤。

<input type="range" name="points" min="1" max="10" 
       step="0.25" onchange="alert(this.value)"/>

Your mistake take is that you gave .25 instead of 0.25.

你的错误是你给了 0.25 而不是 0.25。

回答by Cyclonecode

The following works for me in chrome, I'm thinking that it's the shortcut step=".25"that won't work

以下在 chrome 中对我有用,我认为这是step=".25"行不通的快捷方式

 <input id="something" type="range" min="0" max="0" step ="0.25" value="5" />

回答by SiamKreative

If you want to make it work in Firefox 4+, you can use the following: HTML5Slider

如果你想让它在 Firefox 4+ 中工作,你可以使用以下内容:HTML5Slider