I'm trying to style some <LI>
elements. I cannot understand why when they are focused on, their color
property turns white. I have tried to include just about every pseudo-selector I know and included color: black
, but for whatever reason in both Chrome and Firefox I see this behavior.
.select__label {
display: block;
}
.select__multiple {
border: 0;
display: block;
outline: 0;
border-collapse: collapse;
}
.select__multiple option {
border-width: 1px 0;
border-style: solid;
border-color: deepSkyBlue;
}
.select__multiple .select__option {
border: 1px solid lightGrey;
color: black;
padding: 12px 10px;
width: 150px;
}
.select__multiple .select__option:hover, .select__multiple .select__option:active, .select__multiple .select__option:visited, .select__multiple .select__option:focus, .select__multiple .select__option:checked, .select__multiple .select__option:selected {
color: black !important;
}
.select__multiple .select__option:checked {
color: black;
border-style: solid;
border-color: deepSkyBlue;
background: #dceff7 linear-gradient(0deg, #dceff7 0%, #dceff7 100%);
}
.select__multiple .select__option:checked + :checked {
border-top-width: 0;
border-top: 1px solid transparent;
}
<span class="select__label">options</span>
<select name="genders" class="select__multiple" multiple="multiple">
<option class="select__option" checked>option 1</option>
<option class="select__option">option 2</option>
<option class="select__option">option 3</option>
<option class="select__option">option 4</option>
<option class="select__option">option 5</option>
</select>
Here is the correct way to prevent it. Add -webkit-text-fill-color
property.
.select__multiple .select__option:checked {
color:black;
border-style: solid;
border-color: deepSkyBlue;
background: #dceff7 linear-gradient(0deg, #dceff7 0%, #dceff7 100%);
-webkit-text-fill-color: black;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With