css - Chrome 认为它是 IE,正在评估条件

标签 css internet-explorer google-chrome conditional-statements

也许我误解了 CSS 条件注释的工作原理,但我认为条件中间的位只会出现在 IE 中……但是 Chrome 和 Firefox 都在评估它,并且左边距不是 35px - 20px...我错过了什么?

.policies li li { margin-left: -20px; }
<!--[if IE]>
.policies li { margin-left: 45px; }
.policies li li { margin-left: 35px; }
<![endif]-->

最佳答案

条件注释只适用于 HTML,不适用于 CSS。一种常见的技术是只为 IE 加载一个单独的外部样式表。最近我开始只为 IE <= 8 加载一个,然后在该样式表中使用 hack 分别针对 IE 6/7/8。

关于css - Chrome 认为它是 IE,正在评估条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8976826/

相关文章:

css - 虚线下划线无法在 Chrome 中正确呈现

python - Chrome webdriver selenium 内存错误 - python 3

css - 如何逐 block 渐进显示图像?

CSS 网格布局 - 使元素根据需要跨越尽可能多的列

css - 关于为每张幻灯片重新定位 Bootstrap Carousel 标题的问题

html - css 中的框以方形着色而不是倾斜

java - Windows 上的 "Temporary Internet Files"文件夹

javascript - 在 IE 中轮询的 setTimeout 间隔是多少比较合适?

javascript - 在 IE 中模拟/填充 history.pushstate()

google-chrome - 在打印预览模式下使用 Chrome 的元素检查器?