如何设置html“select”的选项样式? [英] How to style the option of a html "select"?

查看:246
本文介绍了如何设置html“select”的选项样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的html:

<select id="ddlProducts" name="ddProducts"> 
    <option>Product1 : Electronics </option>
    <option>Product2 : Sports </option>
</select>

现在,我想要的是制作产品的名称(即'Product1','Product2 '等)粗体,其类别(即电子,体育等)以斜体显示,仅使用css。我发现了一个类似的问题关于一岁,但正如在那里提到,它是不可能使用HTML和CSS。希望现在有一个解决方案。任何提示,怪癖或技巧将不胜感激。谢谢。

Now, what I want is to make the name of the product (i.e. 'Product1', 'Product2' , etc) bold, and its categories(viz. Electronics, Sports, etc) italicized, using css only. I found a similar question about an year old, but as mentioned there, it's just not possible using HTML and CSS. Hopefully, there's a solution now. Any hint, quirk or trick would be appreciated. Thanks.

推荐答案

一般来说,你不能。此元素由操作系统呈现,而不是HTML。它不能通过CSS样式。有替换插件看起来像一个SELECT,但实际上是由可以定制样式的常规HTML元素组成。

In general, you can't. This element is rendered by the OS, not HTML. It cannot be styled via CSS. There are replacement plug-ins that look like a SELECT, but are actually composed from regular HTML elements that CAN be styled.

这篇关于如何设置html“select”的选项样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆