更改 HTML Select 箭头背景颜色
Change HTML Select arrow background color
我有一个 select 菜单和选项
在 Firefox 中,它有一个“箭头按钮”
在 Chrome/Edge 中,它不会
如何使 Firefox 的“展开菜单”按钮看起来像 Chrome/Edge?
<select>
<option>Example</option>
<option>Example</option>
<option>Example</option>
<option>Example</option>
</select>
一些 linear-gradient
background-image
技巧:
select {
/* styling */
background-color: black;
color: white;
line-height: 1.5em;
padding: 0.5em 3.5em 0.5em 1em;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-appearance: none;
-moz-appearance: none;
}
select.classic {
background-image: linear-gradient(45deg, transparent 50%, white 50%), linear-gradient(135deg, white 50%, transparent 50%), linear-gradient(to right, black, black);
background-position: calc(100% - 20px) calc(1em + 2px), calc(100% - 15px) calc(1em + 2px), 100% 0;
background-size: 5px 5px, 5px 5px, 2.5em 2.5em;
background-repeat: no-repeat;
}
<select class="classic">
<option>Option</option>
<option>Option</option>
<option>Option</option>
</select>
我有一个 select 菜单和选项
在 Firefox 中,它有一个“箭头按钮”
在 Chrome/Edge 中,它不会
如何使 Firefox 的“展开菜单”按钮看起来像 Chrome/Edge?
<select>
<option>Example</option>
<option>Example</option>
<option>Example</option>
<option>Example</option>
</select>
一些 linear-gradient
background-image
技巧:
select {
/* styling */
background-color: black;
color: white;
line-height: 1.5em;
padding: 0.5em 3.5em 0.5em 1em;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-appearance: none;
-moz-appearance: none;
}
select.classic {
background-image: linear-gradient(45deg, transparent 50%, white 50%), linear-gradient(135deg, white 50%, transparent 50%), linear-gradient(to right, black, black);
background-position: calc(100% - 20px) calc(1em + 2px), calc(100% - 15px) calc(1em + 2px), 100% 0;
background-size: 5px 5px, 5px 5px, 2.5em 2.5em;
background-repeat: no-repeat;
}
<select class="classic">
<option>Option</option>
<option>Option</option>
<option>Option</option>
</select>