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

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

问题描述

我要创建这样一个选择框。我已经能够使用OPTGROUP得到这个树状结构,但我现在面临的改变从默认的颜色选定的选项的默认背景色为这个橙色的问题。
我知道JS的解决方案,但我更感兴趣的是纯HTML / CSS的解决方案。它会更好,如果它会在每个浏览器的工作,但没有pressure;)

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来做到这一点。选择元素的颜色是特定于操作系统的,因此不能用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天全站免登陆