如何写一个CSS黑客为IE 11? [英] How to write a CSS hack for IE 11?

查看:199
本文介绍了如何写一个CSS黑客为IE 11?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何才能入侵或编写css只为IE 11?我有一个网站,看起来不错在IE 11.我只是在这里搜索,但没有找到任何解决方案。

How can I hack or write css only for IE 11? I have a website that looks bad in IE 11.I just search here and there but didnt find any solution yet.

有没有任何css选择器?

Is there any css selector?

推荐答案

使用Microsoft特定的CSS规则组合过滤IE11:

Use a combination of Microsoft specific CSS rules to filter IE11:

<!doctype html>
<html>
 <head>
  <title>IE10/11 Media Query Test</title>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <style>
    @media all and (-ms-high-contrast:none)
     {
     .foo { color: green } /* IE10 */
     *::-ms-backdrop, .foo { color: red } /* IE11 */
     }
  </style>
 </head>
 <body>
  <div class="foo">Hi There!!!</div>
 </body>
</html>

由于以下原因,此工作被过滤:

Filters such as this work because of the following:


当用户代理无法解析选择器(即它不是有效的CSS 2.1)时,它必须忽略选择器和后面的声明块(如果有的话)。

When a user agent cannot parse the selector (i.e., it is not valid CSS 2.1), it must ignore the selector and the following declaration block (if any) as well.

参考

  • How do I target only Internet Explorer 10 for certain situations like Internet Explorer-specific CSS or Internet Explorer-specific JavaScript code?
  • Microsoft Extensions to CSS
  • CSS 2.1:Rule sets, declaration blocks, and selectors

这篇关于如何写一个CSS黑客为IE 11?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆