[英]How to prevent color change in a option item from and selected element in html when is checked and lost focus?
I have a stylized SELECT element. 我有一个程式化的SELECT元素。 When I click and element every work fine. 当我单击和元素时,一切正常。 But if change the focus, the checked element change the color. 但是,如果更改焦点,则选中的元素会更改颜色。
Here is the code: 这是代码:
<style>
.extracts-view__select-menu {
font-family: 'OpenSansRegular', Open Sans, Arial, sans-serif;
font-size: 16px;
width: 100%;
margin-right: -20px;
border: 0;
color: #F1F1F1;
font-weight: 500;
line-height: 26.4px;
overflow: hidden;
list-style-type: none;
}
.extracts-view__select-menu:focus {
border: 0;
outline: none;
}
.extracts-view__menu-item {
padding: 8px 16px;
background: #FFFFFF;
color: #18A592;
box-shadow: inset 368px 38px #FFFFFF;
}
.extracts-view__menu-item:hover {
outline: 1px solid #18A592;
}
.extracts-view__menu-item:checked {
color: #FFFFFF;
box-shadow: inset 368px 38px #18A592;
font-weight: bolder;
}
</style>
<p>Hello World !</p>
<select
size="5"
class="extracts-view__select-menu">
<option class="extracts-view__menu-item">Transferencia banco de españa</option>
<option class="extracts-view__menu-item">Extracto integrado</option>
<option class="extracts-view__menu-item">Embargos</option>
<option class="extracts-view__menu-item">Domiciliaciones</option>
Here is the same code for review: http://jsbin.com/yeziwi/edit?html,output 这里是相同的代码以供审查: http : //jsbin.com/yeziwi/edit?html,输出
The steps for reproduce the error are: 重现该错误的步骤是:
Click on a option, then click in "Hello World". 单击一个选项,然后单击“ Hello World”。 The color of the checked option change to black. 选中的选项的颜色变为黑色。
I want to be white. 我想变白。
Try to use pseudo class :active not checked 尝试使用伪类:active未选中
.extracts-view__menu-item:active {
color: #FFFFFF;
box-shadow: inset 368px 38px #18A592;
font-weight: bolder;
}
Could be also a set of the browser, you can make a normalize and add 也可以是一组浏览器,可以进行规范化并添加
a:active{your code}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.