开发者

HTML <br /> inside a Select Box

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.


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.


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.


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.


You could simple add an option disabled in blank

<option disabled selected value> </option>


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜