如何更改选择中悬停选项的背景颜色和文本? [英] How to change background color and text of hover options in select?

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

问题描述

我想在悬停时将此蓝色更改为透明,并将文本颜色更改为红色

I want to change this blue to transparent and the text color to red on hover

推荐答案

这是一个工作示例.- 单个选择选项无法设置样式.

Here is a working example. - A single select option cannot be styled.

我们在这里所做的是使用在点击时触发的 size 将选择更改为多选.转换为多选后,您可以设置选项悬停样式.

What we are doing here is changing the select to multiple selects using size which is triggered onclick. Once converted to a multiple select you can then style the option hover.

.blue:hover {background: blue;}

.green:hover {background: green;}

.red:hover {background: red;}

<select onfocus='this.size=3;' onblur='this.size=0;' 
            onchange='this.size=1; this.blur();'>
<option class="blue" >blue background</option>
<option class="green" >green background</option>
<option class="red" >red background</option>
</select>

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

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