<分区>
我如何破解或编写仅适用于 IE 11 的 css?我有一个在 IE 11 中看起来很糟糕的网站。我到处搜索但还没有找到任何解决方案。
有没有css选择器?
<分区>
我如何破解或编写仅适用于 IE 11 的 css?我有一个在 IE 11 中看起来很糟糕的网站。我到处搜索但还没有找到任何解决方案。
有没有css选择器?
最佳答案
使用 Microsoft 特定 CSS 规则的组合来过滤 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>
过滤器之所以起作用,是因为以下原因:
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.
<!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>
引用资料
关于css - 如何为 IE 11 编写 CSS hack?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20541306/
相关文章:
javascript - 滚动到页面底部时jQuery加载内容
html - 为什么我的不是 :visited style work in Chrome or IE?
internet-explorer-11 - 如何获取 Internet Explorer 11 更新发行说明
javascript - 表单/JavaScript 无法在 IE 11 上运行并出现错误 DOM7011
python - 如何使用 selenium 在 Twitter 登录页面中单击下一步 - Python