选项上的背景图片 [英] Background images on options
问题描述
我想要一个< select>
元素,其中每个< option>
一个图标。
我可以使用< select size =5>
每个图标与选项一致的< select>
的背景图像,但是它强烈依赖于< option> / code>可预测(不是)。
我可以将不同的背景颜色应用于不同的选项, p>
实际上,这个问题可以扩展到< option>
标签?
如果你想保证跨浏览器兼容性,唯一的方法是使用自定义的小部件,而不是< select>
元素。
如果您的兼容性有限,请说明目标浏览器。
I'd like to get a <select>
element where each <option>
is labelled with an icon.
I can achieve this using <select size="5">
, by applying a background image to the <select>
that has each icon coincide with an option, but that relies strongly on the height of the <option>
being predictable (which is isn't).
I can apply individual background colours to different options, so why not a background image?
Actually, this question can be extended to cover "What style properties can and can't be used on <option>
tags?"
You cannot reliably style elements like that across browsers; some of them will allow you to insert backgrounds and such, some will not.
If you want guaranteed cross-browser compatibility the only way is to use custom widgets instead of <select>
elements.
If you are OK with limited compatibility, state your target browsers.
这篇关于选项上的背景图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!