在选择框中更改所选选项的背景颜色 [英] Changing the background color of the selected options in a select box

查看:93
本文介绍了在选择框中更改所选选项的背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

>

创建一个这样的选择框。我已经能够得到这个树结构使用optgroup但我面临的问题,将所选选项的默认背景颜色从默认颜色更改为橙​​色。
我知道js解决方案,但我更感兴趣的纯HTML / CSS解决方案。 )

I have to create a select box like this. I have been able to get this tree structure using optgroup but I am facing problems in changing the default background color of the selected option from default color to this orange color. I am aware of js solutions but I am more interested in pure HTML/CSS solution. It would be better if it will work in every browser, but no pressure ;)

提前感谢。

推荐答案

这是不可能这样做的HTML / CSS。 select元素的颜色是特定于操作系统的,因此无法使用CSS或HTML进行更改。 Javascript解决方案已经开发,他们是(迄今为止)唯一的方法:)

It is not possible to do this with HTML/CSS. The colors of the select elements are Operating System specific and so cannot be changed with CSS or HTML. Javascript solutions have been developed and they're (so far) the only way to do it :)

这篇关于在选择框中更改所选选项的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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