HTML
>在选择框内

发布于 2024-08-11 12:36:53 字数 62 浏览 2 评论 0原文

我想知道是否可以将一个项目分成选择框中的两行。

我的选择框的值之一是两个长以适合我的 div。

I would like to know if there is anyway I can divide an item on two line inside a select box.

One of the values of my select box is two long to fit in my div.

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

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

发布评论

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

评论(6

多孤肩上扛 2024-08-18 12:36:53

不,这是不可能的。

您可以考虑使用 javascript 小部件,例如 这个 jQuery 插件在。

我还可以说,您尝试做的事情并不常见 - 即使在桌面应用程序中,用户也不希望在下拉框中找到包装文本,并且如果他们确实看到文本,可能会感到困惑。最好尝试不同的控件或尝试限制文本。

No, this is impossible.

You can consider using a javascript widget, like this jQuery plug-in.

May I also say that what you are trying to do is uncommon - even in desktop applications users don't expect to find wrapped text in a drop-down box and may get confused if they do see one. It would be better to try a different control or try to limit the text.

×眷恋的温暖 2024-08-18 12:36:53

这是不可能的,但如果只是为了避免元素变得太宽,您可以定义一个宽度(例如

It is impossible, but if it's simply a matter of avoiding that the element gets too wide you could just define a width (eg. <select style="width:100px;">). This will cause text to be cut off when the box is "closed", but as soon as you "open" it the entire text will be shown.

故事灯 2024-08-18 12:36:53

据我所知,这是不可能的。不过,我会查看 jQuery 的选项。具体来说,有一些 jQuery 插件允许自定义选择框。

Select Box Factory 2.0 是一种选择。我相信它扩展了选择框的功能,以允许在其他功能中进行文本换行。

As far as I know, it's impossible. However, I'd look at jQuery for options. Specifically, there are jQuery plugins that allow for select box customization.

Select Box Factory 2.0 is one option. I believe it extends the functionality of the select box to allow text wrapping among other features.

梦明 2024-08-18 12:36:53

中添加禁用选项

您可以简单地在空白<选项禁用所选值>

You could simple add an option disabled in blank

<option disabled selected value> </option>

你げ笑在眉眼 2024-08-18 12:36:53

将选择框中的两行中的项目分开。

你为什么要这么做?如果您使用 JQuery 插件使 HTML 显示在选项标记内,那么我认为没有理由问这个问题,因为您已经能够添加
标记。

要在选择元素中留出间距,您可以做的是创建一个空白选项标签,该标签具有空值和名称。然后,您必须验证提交以检测是否提交了空白值。

Divide an item that's on two lines in a select box.

Why would you want to do that? If you're using a JQuery plugin to make HTML display inside an option tag, then there would be no reason to ask this question, I don't think, as you would be already able to add a
tag.

What you can do to make spacing in select elements, is to create a blank option tag, that has an empty value and name. You would then have to validate the submission to detect if a blank value was submitted.

我不吻晚风 2024-08-18 12:36:53

如果您确实需要,一个黑客解决方案是截取两行文本的屏幕截图,并在选择框中使用图像。

http://www.jquerybyexample。 net/2012/05/how-to-add-images-in-dropdown-list.html

只需确保在图像上设置 alt 标记即可访问。

If you are really in need, a hacky solution would be to take a screenshot of the text on two lines, and use images in your select box.

http://www.jquerybyexample.net/2012/05/how-to-add-images-in-dropdown-list.html

Just be sure to set the alt tag on the images for accessibility.

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