简体   繁体   English

在 css 中定位 IE 11 不起作用

[英]Targeting IE 11 in css not working

I'm trying to fix a tiny layout issue in IE11 where slider pip jumps out of its place (it's fine in the rest of major browsers)我正在尝试修复 IE11 中的一个微小布局问题,其中滑块 pip 跳出其位置(在其他主要浏览器中都很好)

I've added media query to stylesheet (below) but no luck.我已将媒体查询添加到样式表(如下)但没有运气。 I've also tried conditional code, various hacks etc. But nothing worked or affected all browsers.我也尝试过条件代码、各种黑客等。但没有任何效果或影响所有浏览器。 I've spent a couple of hours trying various solutions without any luck and ran out of ideas.我花了几个小时尝试各种解决方案但没有任何运气并且没有想法。 Need help please.需要帮助请。 Layout issue illustrated布局问题说明

  @media screen and (-ms-high-contrast: active),
  (-ms-high-contrast: none) {
    #yardstick-text-6-1 {
      margin-top: -43px;
    }
    #yardstick6-1 {
      margin-top: -53px;
    }
  }

The web page can be seen here with password:quote321网页可以在这里看到密码:quote321

Try using just (-ms-high-contrast: none) like this:尝试只使用(-ms-high-contrast: none)像这样:

@media screen and (-ms-high-contrast: none) {
  #yardstick-text-6-1 {
    margin-top: -43px;
  }
  #yardstick6-1 {
    margin-top: -53px;
  }
}

or :-ms-fullscreen,:root .selector ::-ms-fullscreen,:root .selector :

_:-ms-fullscreen,
:root #yardstick-text-6-1.ie11 {
  margin-top: -43px;
}
_:-ms-fullscreen,
:root #yardstick-6-1.ie11 {
  margin-top: -53px;
}
<div id="yardstick6-1" class="ie11">
  <div id="yardstick-text6-1" class="ie11"></div>
</div>

See BrowserHacks for IE请参阅IE 的 BrowserHacks

Note: To fix easily you can remove float:left from #yardstick6注意:要轻松修复,您可以从#yardstick6删除float:left

The following should solve your problem.以下应该可以解决您的问题。 The idea is to apply CSS specific to IE.这个想法是应用特定于 IE 的 CSS。

@media all and (-ms-high-contrast:active), all and (-ms-high-contrast:none) {
 //Your CSS
}

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

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