更改HTML中透明的下拉列表的背景颜色 [英] Changing the background color of a drop down list transparent in html
本文介绍了更改HTML中透明的下拉列表的背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将HTML下拉列表的背景颜色更改为透明。
I'm trying to change the background color of a drop down list in HTML to transparent.
<select id="nname">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
CSS
CSS
#nname {
padding: 5px;
color: #000;
font-size: 12px;
background: transparent;
-webkit-appearance: none;
}
但是,背景保持白色,文本保持黑色。有任何想法吗?
however, the background stays white and the text stays black. Any ideas?
推荐答案
您实际上可以伪造选项的透明度
具有以下CSS的DOMElements:
You can actualy fake the transparency of option
DOMElements with the following CSS:
option {
/* Whatever color you want */
background-color: #82caff;
}
参见演示
选项
标签不支持 rgba
颜色呢。
See Demo
The option
tag does not support rgba
colors yet.
这篇关于更改HTML中透明的下拉列表的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文