简体   繁体   English

为什么与 Chrome 相比,Firefox 中的 Bootstrap 3 日期输入看起来不同?

[英]Why does a Bootstrap 3 date input look different in Firefox compared to Chrome?

Would anyone happen to know why there is a difference between the appearance of a Bootstrap 3 date picker input in Mozilla Firefox (as of version 69.0.1) and Google Chrome (version 77.0.3865.120)?有谁知道为什么在 Mozilla Firefox(版本 69.0.1)和 Google Chrome(版本 77.0.3865.120)中 Bootstrap 3 日期选择器输入的外观有所不同?

Is it possible to fix the appearance and if so, how could I fix this?是否可以修复外观,如果可以,我该如何解决? The problem is that the value tries to stick to the bottom of any given date input in Firefox.问题是该值试图坚持到 Firefox 中任何给定日期输入的底部。

In Google Chrome:在谷歌浏览器中:

Chrome 示例日期输入

In Mozilla Firefox:在 Mozilla Firefox 中:

Firefox 示例日期输入

 <link href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script> <div class="container"> <div class="row"> <div class="col-md-12"> <div class="form-group"> <label for="sampleInput">Sample input</label> <input type="date" class="form-control" id="sampleInput" placeholder=""> </div> </div> </div> </div>

JSFiddle JSFiddle

As Tyler mentions in the comments, this is caused by the media query正如泰勒在评论中提到的,这是由媒体查询引起的

@media screen and (-webkit-min-device-pixel-ratio: 0)

in bootstrap.min.css.在 bootstrap.min.css 中。 This has the -webkit- prefix, so it is designed to be used only in Webkit based browsers, but the problem is that Firefox has a setting that makes it process the -webkit- prefix too, which causes this issue.这有-webkit-前缀,因此它被设计为仅用于基于 Webkit 的浏览器,但问题是 Firefox 有一个设置使其也处理-webkit-前缀,这导致了这个问题。

To switch this feature off, go to about:config in Firefox and set either layout.css.prefixes.webkit or layout.css.prefixes.device-pixel-ratio-webkit to false . To switch this feature off, go to about:config in Firefox and set either layout.css.prefixes.webkit or layout.css.prefixes.device-pixel-ratio-webkit to false . (Which one of those two will work, seems to depend on the version of Firefox.) (这两者中的哪一个会起作用,似乎取决于 Firefox 的版本。)

Or if you don't want your users to go changing advanced settings in Firefox, you can undo the Bootstrap CSS by setting the line-height for those inputs back to normal in your own CSS. Or if you don't want your users to go changing advanced settings in Firefox, you can undo the Bootstrap CSS by setting the line-height for those inputs back to normal in your own CSS.

input[type=date].form-control,input[type=datetime-local].form-control,input[type=month].form-control,input[type=time].form-control {
  line-height:normal;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么该页面在IE,Firefox和Chrome之间不一样 - Why does this page look different between IE, Firefox & Chrome mayday:更新后,与 Chrome/Firefox 相比,IE 中的 CSS 字体看起来非常不同 - mayday: CSS fonts look horrible different in IE compared to Chrome/Firefox after update 为什么这个小页面在Chrome和Firefox中看起来不同,这是一个错误吗? - Why this small page look different in Chrome and Firefox, is this a bug? HTML / CSS:Firefox上的表单确实与chrome上的表单有所不同 - HTML / CSS: Form does look different on firefox than on chrome 为什么Chrome,Firefox和IE上的文本看起来比Safari模糊? - Why does text on Chrome, Firefox, and IE look fuzzier than Safari? 与chrome相比,为什么Safari对待的转换翻译会有所不同? - Why does Safari treats transform translate different when compared to chrome? 我在Mozilla Firefox中输入的日期与Google Chrome不同 - My input date in Mozilla Firefox is different with Google Chrome 为什么Chrome和Firefox呈现的引导CSS与Safari不同 - Why Chrome & Firefox render bootstrap CSS different than Safari 为什么我的响应代码在 iPhone 上看起来与缩小 window 相比有所不同? - Why does my responsive code look different on an iPhone compared to slimming window down? Google Chrome和Firefox外观不同 - Different look between Google Chrome and Firefox
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM