【发布时间】:2019-10-29 22:18:51
【问题描述】:
我想用 css 编辑/更改下拉样式,特别是下拉箭头。 箭头在 Mozilla firefox 中看起来很完美,但在 google chrome 中它有点难看(他的边框不好)。 我怎样才能在两个浏览器(firefox 和 chrome)中获得相同的结果,而在这个项目和我使用的任何项目中没有任何 1% 的差异?
此图显示了该按钮在 firefox 中的显示方式: https://ibb.co/whTPVt3 此图显示了按钮如何以 chrome 显示: https://ibb.co/35b2Y6D
HTML代码:
<select class="round">
<option>Search type</option>
<option>Room</option>
<option>Device</option>
<option>Tourist</option>
</select>
CSS 代码:
select {
/* styling */
background-color: #314669;
border: thin solid #314669;
border-radius: 50px;
display: inline-block;
font: inherit;
line-height: 1.5em;
padding: 0.5em 3.5em 0.5em 1em;
color: white;
/* reset */
margin: 0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-appearance: none;
-moz-appearance: none;
}
/* arrows */
select.round {
background-image:
linear-gradient(45deg, transparent 50%, yellow 50%),
linear-gradient(135deg, yellow 50%, transparent 50%),
radial-gradient(#314669 65%, transparent 72%);
background-position:
calc(100% - 20px) calc(1em + 2px),
calc(100% - 15px) calc(1em + 2px),
calc(100% - .5em) .5em;
background-size:
5px 5px,
5px 5px,
1.5em 1.5em;
background-repeat: no-repeat;
}
【问题讨论】:
-
不,不是,请仔细阅读我的问题:)
-
how-do-i-style-a-select-dropdown-with-only-css 展示了如何使用图像进行选择,但此请求是通过不使用图像来实现的,因此对我来说接缝不是重复。
标签: css google-chrome firefox