Why we can't style option of dropdown using CSS? [duplicate]

ⅰ亾dé卋堺 提交于 2019-12-12 17:19:54

问题


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.


回答1:


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.




回答2:


There a duplicate method for this... its correct dropdown not accept the styling so you can make the thing which look like dropdown and give styling to that thing.. Here is the link of this explaination check Answer7

css style on select option



来源:https://stackoverflow.com/questions/43406185/why-we-cant-style-option-of-dropdown-using-css

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!