将光标更改为 <option>标签? [英] Change cursor over <option> tags?
问题描述
将鼠标悬停在 组合框中的项目上时,是否有任何方法可以更改光标?我假设做
option { cursor: pointer;}
在 CSS 中可以工作,但似乎不行.
Is there any way to change the cursor when hovering over an item in a <select>
combobox? I assumed that doing option { cursor: pointer; }
in CSS would work, but it doesn't seem to.
推荐答案
制作自己的下拉菜单
标签是由操作系统呈现的,而不是浏览器,因此您无法设置它们的样式.
Make your own dropdown
<option>
tags are rendered by the operating system, not the browser, so you can't style them.
相反,制作自己的下拉菜单,您可以完全控制或使用第 3 方插件,例如 Bootstrap下拉.
Instead, make your own dropdown that you can fully control or use a 3rd-party plugin, for example Bootstrap's Dropdown.
除了背景颜色和颜色之外,通过样式对象为选项元素应用的样式设置将被忽略.此外,直接应用于单个选项的样式设置会覆盖应用于整个包含 select 元素的样式设置.
Except for background-color and color, style settings applied through the style object for the option element are ignored. In addition, style settings applied directly to individual options override those applied to the containing select element as a whole.
有些元素根本无法使用 CSS 设置样式.这些包括所有高级用户界面小部件,例如范围、颜色或日期控件以及所有下拉小部件,包括 、
、
和
元素.众所周知,文件选择器小部件根本没有样式.新的
和
元素也属于这一类.
Some elements simply can't be styled using CSS. These include all advanced user interface widgets such as range, color, or date controls as well as all the dropdown widgets, including
<select>
,<option>
,<optgroup>
and<datalist>
elements. The file picker widget is also known not to be stylable at all. The new<progress>
and<meter>
elements also fall in this category.
这篇关于将光标更改为 <option>标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!