我不想为此使用 JS,请仅使用 css 解决方案。
我希望包含 div 内的列能够均匀地放入其中,即每个列都是容器宽度的三分之一。我在这里实现了这一点 - http://jsfiddle.net/yFxZX/
但是,除此之外,我还想要10px margin在列之间,第一列亲吻容器的左边缘,右列亲吻容器的右边缘。请参阅下图以了解粗略的模型。
当浏览器重新调整大小或父容器改变宽度时,我希望列相应地调整大小以填充空间,但它们之间的边距保持固定在 10px。
这可以在没有 JS 的情况下完成吗?

我不想为此使用 JS,请仅使用 css 解决方案。
我希望包含 div 内的列能够均匀地放入其中,即每个列都是容器宽度的三分之一。我在这里实现了这一点 - http://jsfiddle.net/yFxZX/
但是,除此之外,我还想要10px margin在列之间,第一列亲吻容器的左边缘,右列亲吻容器的右边缘。请参阅下图以了解粗略的模型。
当浏览器重新调整大小或父容器改变宽度时,我希望列相应地调整大小以填充空间,但它们之间的边距保持固定在 10px。
这可以在没有 JS 的情况下完成吗?

使用负边距:
.container {
background: green;
overflow: auto;
}
.inner {
padding-left: 20px;
}
.box {
width: 33.3%;
background: red;
float: left;
margin-right: 10px;
}
.first {
margin-left: -20px;
}
.last {
width: 33.4%;
margin-right: 0;
/*float:right;*/
}
img {
max-width: 100%;
height: auto;
width: auto\9;
/* ie8 */
}
在 HTML 中:
<div class="container">
<div class="box">
<div class="box-content">
First
</div>
</div>
<div class="box">
<div class="box-content">
SECOND
</div>
</div>
<div class="box last">
<div class="box-content">
Last
</div>
</div>
</div>
在 CSS 中:
.container {
background: green;
overflow: auto;
}
.box {
width: 33.3%;
float: left;
}
.box.last {
width: 33.4%;
}
.box .box-content {
margin-right: 10px;
background: red;
}
.box.last .box-content {
margin-right: 0px;
background: red;
}
如果你希望你的盒子在 css 中具有相同的高度,请添加:
.box .box-content {
margin-right: 10px;
background: red;
margin-bottom: -1000px;
padding-bottom: 1000px;
}