简体   繁体   English

内部自定义CSS样式 <option>展开标签<select>名单

[英]Customized CSS styles inside <option> tag in expanded <select> list

I was wondering if there are other ways to customize an expanded select list using HTML or even a jQuery plugin. 我想知道是否还有其他方法可以使用HTML甚至是jQuery插件来自定义扩展选择列表。 Basically I want each option in the list to be rendered with multiple styles, like in this example where the number is colored red: 基本上,我希望列表中的每个选项都以多种样式呈现,例如在此示例中,数字用红色表示:

<select size="12" name="ddlSpecial" id="ddlSpecial">
    <option value="1">
        <div>Option text <span style="color:Red;">(1)</span></div>
    </option>
    <option value="2">
        <div>Option text <span style="color:Red;">(1)</span></div>
    </option>
</select>

The HTML above works only in Firefox while the other browsers strip out the styling: 上面的HTML仅在Firefox中可用,而其他浏览器会删除样式:

http://i.stack.imgur.com/TqZuc.jpg http://i.stack.imgur.com/TqZuc.jpg

Check this out: 看一下这个:

http://www.jankoatwarpspeed.com/post/2009/07/28/reinventing-drop-down-with-css-jquery.aspx http://www.jankoatwarpspeed.com/post/2009/07/28/reinventing-drop-down-with-css-jquery.aspx

you can do it, but you basically gonna have to replace the normal select with ul 您可以做到,但基本上您必须用ul替换常规选择

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM