假设您希望列的高度至少为 100%,那么还有这个解决方案:
http://jsbin.com/emujeb/1/edit
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<div class="wrap1">
<div class="wrap2">
<div class="col">
col
</div>
<div class="col">
col
</div>
<div class="col">
col
</div>
<div class="col">
col
</div>
</div>
</div>
</body>
.col {
width:25%;
float:left;
}
body {
margin:0px;
padding:0px;
background-image: -webkit-gradient(
linear,
left top,
right top,
color-stop(0, #eee),
color-stop(25%, #eee),
color-stop(25%, #ccc),
color-stop(50%, #ccc),
color-stop(50%, #eee),
color-stop(75%, #eee),
color-stop(75%, #ccc),
color-stop(100%, #ccc)
);
background-image: -webkit-linear-gradient(
left,
#eee,
#eee 25%,
#ccc 25%,
#ccc 50%,
#eee 50%,
#eee 75%,
#ccc 75%,
#ccc 100%,
#eee 100%
);
background-image: -moz-linear-gradient(
left,
#eee,
#eee 25%,
#ccc 25%,
#ccc 50%,
#eee 50%,
#eee 75%,
#ccc 75%,
#ccc 100%,
#eee 100%
);
background-image: -ms-linear-gradient(
left,
#eee,
#eee 25%,
#ccc 25%,
#ccc 50%,
#eee 50%,
#eee 75%,
#ccc 75%,
#ccc 100%,
#eee 100%
);
background-image: -o-linear-gradient(
left,
#eee,
#eee 25%,
#ccc 25%,
#ccc 50%,
#eee 50%,
#eee 75%,
#ccc 75%,
#ccc 100%,
#eee 100%
);
}
这是通过 css 渐变完成的,但如果您不喜欢背景图像并使用仿列技术,则可以将它们替换。
您需要将 html,body,wrap1,wrap2 设置为 4 列,并使用背景位置 % 来实现。请注意,您将需要长 1px 高的图像来表示颜色,html 将使图像显示为 25% bakcground 颜色透明,body 将显示为 50%,依此类推。