为什么我们不能使用CSS设计下拉式选项? [英] Why we can't style option of dropdown using CSS?

查看:108
本文介绍了为什么我们不能使用CSS设计下拉式选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Css中,我们可以通用样式化所有元素,但是我注意到我们不能使用CSS对选择元素的元素进行样式化。据我所知,Option是的子元素,选择然后有可能导致它不让你设计这个元素?



我已经在stackoverflow上回答了各种答案,指出您不能设计样式选项。但我想知道背后的确切原因。



我已经接受了此链接表示该选项标记由OS呈现,而不是由html呈现。如果是这样,那么为什么我们需要指定选项?为什么它不会自动呈现选项。



这里是另一个显示如何选择标签样式的链接。但我想知道为什么我们不能设计选项?我不想知道如何使用CSS来设计选择标签。

解决方案

您不能设计选项元素,因为它是由操作系统渲染的,而不是HTML。这就是为什么它不能通过CSS进行样式设计。



当然,您可以使用一些插件来替换 select 以及可以设置样式的常规HTML元素。

In Css we can genrally style all elements but I noticed that we can not style option element of a select using CSS. As far as I know Option is child element of select then what is possible causes that it don't let you style this element?

I've had reffered various answers on stackoverflow stating that You just can't style option. but I want to know exact reason behind it.

I've had reffered this link which says that option tag is rendered by OS and not by html. If so then why we need to specify option ? why it don't automattically render options.

Here is another link which shows how to style Select tag. But i want to know that why we can't style option? I don't want to know how to style select tag using CSS.

解决方案

You cannot style the option element because it is rendered by the OS, not HTML. That is why it can't be styled via CSS.

You can of course use some plug-in that replaces select with regular HTML elements that can be styled.

这篇关于为什么我们不能使用CSS设计下拉式选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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