css - 在 IE7 和 IE8 中使用多类选择器

标签 css internet-explorer-8 internet-explorer-7

我知道 IE7 和 IE8 应该支持使用多个 CSS 类选择器,但我似乎无法让它工作。

CSS:

.column {
  float: left;
  display: block;
  margin-right: 20px;
  width: 60px;
}
.two.column {
  width: 140px;
}
.three.column {
  width: 220px;
}
.four.column {
  width: 300px;
}

HTML:

<div class='two column'>Two Columns</div>
<div class='three column'>Three Columns</div>
<div class='four column'>Four Columns</div>

它总是以使用 .four.column 规则结束。对我做错了什么有什么想法吗?

最佳答案

您想确保并使用一种文档类型,这样您就不会在怪癖模式下呈现。例如:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test Page</title>
<style type="text/css">
.column {
  float: left;
  display: block;
  margin-right: 20px;
  width: 60px;
  border: 1px solid;
}
.two.column {
  width: 140px;
}
.three.column {
  width: 220px;
}
.four.column {
  width: 300px;
}
</style>
</head>
<body>
<div class="two column">Two Columns</div>
<div class="three column">Three Columns</div>
<div class="four column">Four Columns</div>
</body>
</html>

关于css - 在 IE7 和 IE8 中使用多类选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1671178/

相关文章:

javascript - 安装 JQuery 时更改了哪些文件

Javascript提示-数据隐藏在ie中

css - IE7+ 中的容器 "pushed down"

html - 在 IE8 和 IE 10 中的不同位置

iis-7 - IE8 不保留 session 变量

javascript - wordpress 插件在 IE7 和 8 中不工作

javascript - 为什么当我在 IE7 中隐藏 DIV 时,我的单选按钮全部取消选择?

html - 将 TEXTAREA 和 INPUT 字段设置为 TD 内的 100% 宽度会截断右边距

CSS 垂直对齐占位符文本

html - 鼠标悬停不能实时工作,在预览中工作