css - 与 Firefox 相比,Google chrome 显示了不同的结果
问题描述
我想用 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;
}
解决方案
检查元素并在开发人员工具中对 Chrome 或 Firefox 进行更改,然后仅为 Firefox 或 Chrome 编写 css。
目标火狐:
@-moz-document url-prefix() {
h1 {
color: green;
}
}
目标铬:
@media screen and (-webkit-min-device-pixel-ratio:0) and (min-resolution:.001dpcm) {
.h1 {
color: green;
}
}
推荐阅读
- git - 如何使用`git svn dcommit`而不是整个提交集将特定提交推送到svn?
- android - 仅考虑Android中一天中的一天时间计算2个给定时间戳之间的时间差?
- javascript - Google Cloud Functions 结束时:使用 Axios 时超时
- c# - 如何在特定时间更改标签文本
- scala - 类文件中的常量池数据不一致
- java - 如何使用整数参数的二进制表示过滤数组?
- jenkins - 詹金斯管道:当条件和水银标签
- c# - Postgres 10 池化问题
- c++ - 可以编译 Gtk+ 应用程序以在 Gtk 2 和 3 上运行吗
- postgresql - 如何在以前使用 JPA 的项目中使用 R2DBC 实现 OneToMany、ManyToOne 和 ManyToMany?