【发布时间】:2014-10-17 20:57:47
【问题描述】:
经过多次实验,我想出了一种在花车之间添加固定、相等的排水沟的方法。我的解决方案包括正负边距和许多包装器,因此看起来有些麻烦。不过,我认为它是最终的,直到我意识到它只适用于等高的花车。
这是一个演示:http://jsfiddle.net/aaand/qnS2b/
我在追求这个:
+-------------------------------+
|+---+ GUTTER +---+ GUTTER +---+|
|| | | | | ||
|+---+ +---+ +---+|
+-------------------------------+
结构如下:
<div class="container-with-negative-margins">
<div class="floated-container-with-set-width">
<div class="container-with-positive-margins">
<p>sample text</p>
</div>
</div>
</div>
这是一些示例 css:
.container-with-negative-margins {
margin: -10px;
}
.floated-container-with-set-width {
float: left;
width: 33.33%;
}
.container-with-positive-margins {
margin: 10px;
/* the jsfiddle includes a fixed height and overflow: hidden, but I don't want that */
}
如果我添加内容以使<div>s 不再具有相同的高度,它就不再起作用了。
有什么想法吗?
【问题讨论】: