更改选择悬停在html中的列表选项背景颜色 [英] Change Select List Option background colour on hover in html

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

问题描述

是否可以更改悬停时选择列表选项的默认背景颜色?

Is it possible to change the default background color of the select list option on hover?

HTML:

<select id="select">
    <option value="1">One</option>
    <option value="2">Two</option>
    <option value="3">Three</option>
</select>



select {
    -webkit-border-radius:25px; -moz-border-radius:25px; border-radius:25px;
}

select:hover {    
    background-color:gren;
}

option:hover {
    background-color:yellow;
}

option {
    -webkit-border-radius:25px; -moz-border-radius:25px; border-radius:25px;
    color:blue;
    background-color:yellow;
}

我尝试过选项:hover {background-color :red;} ,但它没有用。有没有人知道如何做到这一点?

I have tried option :hover{background-color:red;}, but it is of no use. Does anybody know how to do this?

推荐答案

目前没有办法应用css来获得你想要的结果。为什么不使用选择 select2

Currently there is no way to apply a css to get your desired result . Why not use libraries like choosen or select2 . These allow you to style the way you want.

如果你想使用第三方库,那么你可以做一个简单的无序列表和一些css播放。这是您可以关注的主题

If you don want to use third party libraries then you can make a simple un-ordered list and play with some css.Here is thread you could follow

如何转换< select>使用jquery将下拉列入无序列表?

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

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