简体   繁体   English

IE9中的CSS中断

[英]CSS breaks in IE9

I am working on a project where a client has given me a website built using metronic templates. 我正在做一个项目,其中客户给了我一个使用metronic模板构建的网站。 The website looks good in all browsers except IE9 and lower. 该网站在除IE9及更低版本之外的所有浏览器中看起来都不错。

My application.css.scss 我的application.css.scss

@import 'bootstrap';
@import 'font-awesome';
@import 'static/css/style-metronic';
@import 'static/css/style';
@import 'static/css/style-responsive';
@import 'static/css/plugins';
@import 'static/css/themes/default';
@import 'static/plugins/uniform/css/uniform.default';
@import 'static/css/pages/login';
@import 'static/plugins/data-tables/DT_bootstrap';
@import 'static/plugins/select2/select2_metro';
@import 'static/plugins/dropzone/css/dropzone';
@import 'static/plugins/bootstrap-datepicker/css/datepicker';
@import 'static/plugins/bootstrap-timepicker/compiled/timepicker';
@import 'static/plugins/bootstrap-datetimepicker/css/datetimepicker';

When I removed style-metronic (3rd line) the page got rendered properly. 当我删除style-metronic(第3行)时,页面已正确呈现。 So I started by removing each and every style in style-metronic.css. 因此,我首先删除了style-metronic.css中的每个样式。 And finally I found that the below css is the problematic code. 最后,我发现下面的CSS是有问题的代码。

.btn.yellow:hover,
.btn.yellow:focus,
.btn.yellow:active,
.btn.yellow.active,
.btn.yellow.disabled,
.btn.yellow[disabled] {
  background-color: #eca22e !important;
  color: #fff !important;
  outline: none !important;
}

If I remove 如果我删除

.btn.yellow.active,
.btn.yellow.disabled,
.btn.yellow[disabled]

from the last css selector the pages gets rendered properly. 从最后一个CSS选择器可以正确渲染页面。 But even if I add .btn.yellow.active my page breaks again. 但是,即使我添加.btn.yellow.active,我的页面也会再次中断。 My question is what is wrong with the above css selectors in IE9 and how to fix it? 我的问题是上述IE9中的CSS选择器有什么问题,如何解决?

.btn.yellow[disabled] 

I'm guessing that IE needs a value associated with the attribute selector in order to understand it. 我猜想IE需要与属性选择器关联的值才能理解它。 This of course assumes that your HTML includes a value for that attribute. 当然,这假定您的HTML包含该属性的值。 example: 例:

.btn.yellow[disabled='true']

You need a polyfill for older versions of IE to support the latest version of CSS. 您需要老版本的IE的polyfill才能支持最新版本的CSS。

I have used WebShims successfully. 我已经成功使用了WebShims

Modernizr has a huge list of polyfills for any browser need. Modernizr拥有大量可满足任何浏览器需求的polyfill

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM