使用单选按钮或下拉列表

发布于 2024-08-31 20:02:50 字数 311 浏览 3 评论 0原文

嗯,我对 HTML 中的单选组和下拉列表的性质很好奇。我发现单选按钮很难设置样式,但我想为必填字段设置元素的样式。我问了一个关于样式单选按钮和提供边框颜色的问题,就像您可以对文本框所做的那样,例如:

<input type="text" style="border-color:#FF0000">
<input type="radio" style="border-color:#FF0000">

将样式应用于单选按钮以更改边框颜色不起作用。

我的问题是有什么理由我不应该使用下拉列表而不是无线电组?

Well, I curious as to the nature of Radio groups and dropdown lists in HTML. I have found that radio buttons are difficult to style but I would like to style my elements for required fields. I asked a previous question regarding styling radio buttons and giving a border color like you can do with text boxes, example:

<input type="text" style="border-color:#FF0000">
<input type="radio" style="border-color:#FF0000">

applying style to a radio button to change the border color does not work.

My Question is there any reason why I shouldnt use a drop down list insead of a radio group?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

偷得浮生 2024-09-07 20:02:50

下拉列表需要更多的工作(用户方面)来找出可用的选项……并且无论如何,其样式都与单选按钮一样笨拙。

您可以尝试在包含单选组的字段集上设置边框颜色。请记住还使用一些其他方法来指示必需不过字段

Drop down lists require more work (on the part of the user) to find out what options are available … and are as twiddly to style as radio buttons anyway.

You might try setting the border colour on the fieldset containing the radio group instead. Remember to also use some other method for indicating required fields though.

桜花祭 2024-09-07 20:02:50

单选按钮组将比下拉列表在表单上占用更多空间,当然控件的外观也有所不同。我的经验法则是,如果有超过三到四个选择,请使用下拉列表。

A radio group will take more room on your form than a drop down list, and of course the controls look different in appearance. My rule of thumb is if there are more than three or four choices, use a drop down list.

永不分离 2024-09-07 20:02:50

大多数用户(包括大多数没有计算机背景的人和老年人)非常熟悉单选按钮来回答是/否、男性/女性等类型的问题。为了方便用户,使用单选按钮来回答此类问题问题。

Majority of the users (includes mostly people with no computer background and elderly people) are really very familiar with radio buttons to answer questions of the type yes/no , male/female etc. For the convenience of the users use a radio button for such questions.

水染的天色ゝ 2024-09-07 20:02:50

对于下拉列表,用户在交互(单击它)之前看不到可用选项。通过单选按钮,所有可用选项都在用户面前。虽然两者都允许您将选择范围限制为一个选项,但我发现用户可以使用单选按钮更快地决定他们想要哪个选项。如果超过 5 个选项,我会重新考虑。

With Drop down lists the available options are not visible to the user until they interact (click it). With radio buttons all of the available options are in front of the user. While both allow you to limit the selection choices to just one option, I find that users can decide which option they want quicker with radio buttons. If it is more than 5 options though, I would reconsider.

一曲爱恨情仇 2024-09-07 20:02:50

ux.stackexchange。

当一个选择被认为“更重要”并且替代选项可以对用户隐藏时,请使用下拉列表,例如,选择美国的一个州 用户居住在一个州,并且替代选项不可见没关系。当用户来到表单项时,他们不需要查看替代项就确切地知道要选择什么。

另一方面,当所有选项都同等重要,或者用户需要在做出选择之前查看所有选项时,请使用单选按钮,例如,按从 1 到 5 的等级进行评分,或者在选项中选择答案选项。多项选择题。

另一个需要考虑的因素是屏幕空间:您不希望使用单选按钮来选择 50 个州之一,并且您可能不希望使用下拉列表来选择性别(男性或女性)。根据您的设计和理念,这个因素可能会也可能不会胜过上述因素。

Related question on ux.stackexchange.

Use a drop-down list for when one choice is regarded as "more important" and the alternatives are okay as being hidden from the user, for example, selecting a state in the U.S. A user lives in one state, and the alternative choices don't matter. When the user comes to the form item, they know exactly what to choose without looking at the alternatives.

On the other hand, use radio buttons for when the choices are all equally important, or the user needs to see all of them before making a selection, for example, rating on a scale from 1 to 5, or choosing an answer choice on a multiple-choice problem.

Another factor to take into account is screen real-estate: you wouldn't want radio buttons for selecting one of 50 states, and you probably wouldn't want a drop-down list for selecting a sex (Male or Female). Depending on your design and philosophy, this factor may or may not trump the factors stated above.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文