html - 在 IE7-8 中根本不应用 CSS 类

标签 html css internet-explorer css-selectors

<!DOCTYPE html>已设置,html5shim.js已列入<head>每页。

我有 CSS:

.height_fix_container > * { margin:0; background:#fff url(../images/bg.jpg) top left no-repeat; min-height: 400px; }
.height_fix_container > *:first-child { background:#fff; } /*Good eye! But the problem still exists*/

...应用于页面中间的这段代码:

...
<div class="height_fix_container">
    <div>Content box 1</div>
    <div>Content box 2</div>
</div>
...

在除 IE7 和 8 之外的所有浏览器中,CSS 选择器都运行良好。但是,在 IE 中 Content box 1识别选择器但是 Content box 2完全忽略它。我正在使用 IE 中的内置开发人员工具对此进行检查。

为什么会这样?

最佳答案

在 IE 中,您需要声明 DOCTYPE 才能识别第一个子选择器。

<!DOCTYPE .......>

您还缺少第二类定义中“fff”前面的#。它根本不会影响代码,只是语法上的修改。

http://www.w3schools.com/cssref/sel_firstchild.asp

关于html - 在 IE7-8 中根本不应用 CSS 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7491261/

相关文章:

javascript - 启用 html 和 javascript 文件的 IntelliJ 热交换

jquery - 如何替换字符串 jquery 中的任意数量

HTML/CSS : Webkit browsers cut up italic link

css - IE 忽略 zIndex

javascript - window.getComputedStyle 不适用于除 Chrome 之外的其他浏览器中的速记属性

javascript - 在动态位置生成下拉菜单

html - 用图像替换 Font Awesome 图标

javascript - jQuery 使用动画创建循环

html - 过渡和伪元素的组合在 IE 中不起作用?

css - IE7 cleafix 不工作