[英]Fixed-width, flexible-height css grid
NOTE This is similar to this post , however there is a strict no-javascript requirement and the answer should be responsive (ie there is not a fixed number of columns). 注:这是类似这个帖子 ,但是有严格的无JavaScript的要求,答案应该是响应的(即没有列的固定数量)。
I would like to style several fixed width, variable height boxes using no javascript such that they form a kind of fluid grid. 我想不使用JavaScript来设置几个固定宽度,可变高度的框的样式,以便它们形成一种流体网格。 This jsfiddle yields the picture below. 此jsfiddle产生以下图片。 This is essentially just the following css: 本质上,这只是以下CSS:
div {
float: left;
margin: 1em;
border: 1px solid #999;
width: 150px;
}
I'd like for the only vertical empty space to be the margins. 我希望唯一的垂直空白区域为边距。 In terms of the screenshot above, I'd like for the tops of 5
and 6
to move upwards to 1em from the bottom of 1
and 2
, respectively. 根据上面的屏幕截图,我希望5
和6
的顶部分别从1
和2
的底部向上移动到1em。
使用纯CSS是不可能的,因为您必须知道div的当前位置,因此,如果您真的想这样做,则必须使用css的“ margin-top”属性或使用jQuery之类的方法重新定位<div>
这些jqueryhouse.com/jquery-grid-plugins
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.