在 css 中以 IE 11 为目标无效

Targeting IE 11 in css not working

我正在尝试修复 IE11 中的一个小布局问题,其中滑块 pip 跳出其位置(在其他主要浏览器中没有问题)

我已将媒体查询添加到样式表(如下),但没有成功。我也尝试过条件代码、各种 hack 等。但没有任何效果或影响所有浏览器。我花了几个小时尝试各种解决方案,但没有任何运气,而且 运行 没有想法。请需要帮助。 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;
    }
  }

可以看到网页here和password:quote321

尝试像这样只使用 (-ms-high-contrast: none)

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

:-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>

BrowserHacks for IE

注意: 要轻松修复,您可以从 #yardstick6

中删除 float:left

以下应该可以解决您的问题。这个想法是应用特定于 IE 的 CSS。

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