html - 我怎样才能只针对最小宽度为 : 600px in a style sheet? 的 IE(任何版本)

标签 html css internet-explorer media-queries

<分区>

我注意到我元素中的一个 Div 仅在 IE 中未正确对齐。我只想针对 IE(任何版本)来解决这个问题。以下是应用于 div 的样式:

#my-sidebar {
position: absolute;
top: 0;
right: 133px;
margin: 0;
padding: 0;

我需要声明权:133px; 在 IE 中应用,当页面宽度为 600px 及以上时。我怎样才能做到这一点?

最佳答案

为 IE 写一个样式表,对于 IE9 及更低版本,你可以加载一个 IE 特定的样式表。像这样

<!--[if IE]>
    <link rel="stylesheet" type="text/css" href="all-ie-only.css" />
<![endif]-->

然后在该样式表中,将您的代码编写为

@media only screen and (min-width: 600px){
  #my-sidebar {
     position: absolute;
     top: 0;
     right: 133px;
     margin: 0;
     padding: 0;
}

IE10及以上不再支持条件注释。

所以对于 IE10+, 在您的主 css 文件中使用 -ms-high-contrast 创建一个媒体查询,并放置您的 css

@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
     @media only screen and (min-width: 600px){
          #my-sidebar {
               position: absolute;
               top: 0;
               right: 133px;
               margin: 0;
               padding: 0;
          }
     }
}

关于html - 我怎样才能只针对最小宽度为 : 600px in a style sheet? 的 IE(任何版本),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35128882/

相关文章:

javascript - CSS Div 滚动高度

java - 如何获取 webtable 的动态 Xpath?

javascript - $("div")。引用所有div?

javascript - EaselJS 多行 Spritesheet

jquery 只工作一次

css - IE打印字体变小

html - 如何在我的 Angular 2 应用程序中获取此动态 div 的innerHTML?

html - 使 div 适合内联 block 内容

css - @font-face 用于 IE8 奇怪的行为

html - CSS:在不同的标准模式下检测 IE?