如何更改第一个选择选项的文本颜色 [英] How to change the text color of first select option

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

问题描述

我有一个select元素有几个项目。我想改变它的第一个项目的颜色。但是当你点击选择下拉菜单,似乎颜色只显示
。我想要的是在页面加载时改变颜色(如灰色的颜色)
,以便用户可以看到第一个选项颜色改变。

I have a select element which has several items. I want to change the color of its first item. But it seems the color only shows when you click on the select dropdown. What I want is changed the color(like color gray) when the page is loaded so users can see the first option color changed.

...
http://jsbin.com/acucan/4/

感谢您的回答!这是我第一次在这里发布问题。
对不起,我的英语。我希望我提出这个问题。

Thanks for the answer! It's the very first time I post question here. Sorry about my English. I hope that I make the question clear.

感谢

推荐答案

b
$ b

What about this:

select{
  width: 150px;
  height: 30px;
  padding: 5px;
  color: green;
}
select option { color: black; }
select option:first-child{
  color: green;
}

http://jsbin.com/acucan/9

这篇关于如何更改第一个选择选项的文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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