admin管理员组文章数量:1315829
Basically, I want this:
<select size="2">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
But instead of having two lines, I want it on a single line. Can this be done without Javascript?
If not, I would imagine it's mon enough (though I can't find any relevant links on Google) that there exists a standard cross-browser solution for this which would be helpful.
EDIT: The control is also called a stepper or a spinner (this link also has UI guidelines for when to use a spin control)
Solution A:
<select size="2" style="height:40px; font-size:28px;">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
</select>
This solution relies on the fact that the select box is big enough to enable controls but the text is big enough to so that there's only one line of text showing. The problem is that it needs to be quite big for this to work. It works on IE/FF but still precarious because of the browser default text size discrepancies.
Basically, I want this:
<select size="2">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
But instead of having two lines, I want it on a single line. Can this be done without Javascript?
If not, I would imagine it's mon enough (though I can't find any relevant links on Google) that there exists a standard cross-browser solution for this which would be helpful.
EDIT: The control is also called a stepper or a spinner (this link also has UI guidelines for when to use a spin control)
Solution A:
<select size="2" style="height:40px; font-size:28px;">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
</select>
This solution relies on the fact that the select box is big enough to enable controls but the text is big enough to so that there's only one line of text showing. The problem is that it needs to be quite big for this to work. It works on IE/FF but still precarious because of the browser default text size discrepancies.
Share Improve this question edited Sep 21, 2017 at 21:55 P.S. 16.4k14 gold badges65 silver badges86 bronze badges asked Feb 15, 2009 at 1:28 aleembaleemb 32.1k21 gold badges102 silver badges114 bronze badges3 Answers
Reset to default 4You may want to rethink the user interaction side of this before struggling to find a workable JavaScript-free solution.
When a user is presented with a single-line <select>
the default behavior is for a dropdown list to appear. Changing this goes against the user's expectations and may make your form harder to use, ultimately reducing pletion or at least increasing the time involvement to use it.
If you eventually want to allow multiple selections, then a single-line input would be almost impossible to use.
Unless you have legitimate feedback that users would like dropdown lists to behave differently, you may be heading in the wrong direction, at least from a UX perspective.
If you can use JavaScript, it looks like there are some options for spinner controls. One such control has pretty good UI and functionality. Example:
(source: extjs.)
Try this.
<select size="2" style="height:2em;">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
</select>
BTW i agree with Mark
本文标签: javascriptSingle line select box with updown arrows like in a multi line select boxStack Overflow
版权声明:本文标题:javascript - Single line select box with updown arrows like in a multi line select box - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741989743a2408899.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论