简体   繁体   English

在 html select 中悬停或选择项目时,如何避免更改背景颜色?

[英]How can I avoid change of background color when hoovering or selecting an item in a html select?

I have in my page a drop-down for the user to select a color.我的页面中有一个下拉菜单供用户使用 select 一种颜色。

But when the user tries to select a color and hoover the mouse on top of the select items, the browser automatically changes the color of the items, that makes him difficult to make the selection.但是当用户试图给 select 一个颜色并将鼠标悬停在 select 项目之上时,浏览器会自动更改项目的颜色,这使他难以做出选择。

I want to leave the browser to leave the back-color the way it is, maybe when hoovering to draw a yellow border around but not to change the back-color, How can I get that effect?我想让浏览器保持原样的背景颜色,也许当悬停在周围绘制黄色边框但不改变背景颜色时,我怎样才能得到那种效果? This is my select这是我的 select

Defined 定义
<option value="#DC626D" style="background: #DC626D"></option> <option value="#E8825D" style="background: #E8825D"></option> <option value="#FFCD8F" style="background: #FFCD8F"></option> <option value="#FDEE65" style="background: #FDEE65"></option> <option value="#52CE90" style="background: #52CE90"></option>

You can use the css selector option:hover to handle any hover effect.您可以使用 css 选择器选项:hover 来处理任何 hover 效果。

Possibly duplicating this CSS disable hover effect可能复制此CSS 禁用 hover 效果

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM