简体   繁体   English

如何为HTML选择选项悬停和选择的选项效果设置样式

[英]How to style HTML select option hover and selected option effects

I'm trying to remove the default blue background on the HTML select option hover effect and also style the selected option effects with the block of CSS below but it doesn't seem to be working. 我正在尝试删除HTML选择选项悬停效果上的默认蓝色背景,并使用下面的CSS块设置所选选项效果的样式,但这似乎无法正常工作。 Ant ideas on how this can be achieved. 蚂蚁关于如何实现的想法。

    select.color-chooser option:hover {
        background-color: none!important;

    }

select.color-chooser option[selected] {
        background-color: none!important;

    }

You can't do this, if you want you can use jQuery Chosen or similar http://harvesthq.github.io/chosen/ 如果您愿意,可以使用jQuery Chosen或类似的http://harvesthq.github.io/chosen/

It generates HTML lists easy to style. 它生成易于样式化的HTML列表。

Solution works only in IE (checked 10 and 11) 解决方案仅在IE中有效(已选中10和11)

`
    <select class="form-control">
          <option>Option option option</option>
          <option>Option option option</option>
          <option>Option option option</option>
         </select>



          .form-control option:hover {
              background: pink;
            }

            ::selection, select:focus::-ms-value {
              background-color: deeppink;
              color: #000;
            }

            option:checked {
              background-color: deeppink;
              color: #000;
            }

            option:checked:hover, select:focus option:checked:hover {
              background-color: deeppink;
              color: #000;
            }

`

https://jsbin.com/mejivij/2/edit?html,css,js,output https://jsbin.com/mejivij/2/edit?html,css,js,输出

我还没有尝试过,但是我的头上没有,不是应该选择:选择吗?

select.color-chooser option:selected {}

To change the default text colour of blue on a link, use this code: 要更改链接上蓝色的默认文本颜色,请使用以下代码:

a {
text-decoration:none;
  }

To change hovering colour, this should work: 要更改悬停颜色,这应该起作用:

a:hover {
   color:[enter colour];
       }

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

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