CSS内联块不均匀间距

时间:2015-08-24 15:54:01

标签: html css layout

所以我有两列牌,每张牌都有(define (same-parity a .b) (let ((remain (remainder a 2))) (define (recur-part remain-list) (cond ((= remain (remainder (car remain-list) 2)) (append remain-list (list (car remain-list))) (recur-part (cdr remain-list))) (else (recur-part (cdr remain-list))))) (recur-part b))) 属性。每个都是可变高度,因此每张卡之间有不均匀的空白区域,如下所示:

inline-block

如果没有两个独立的列,我怎样才能在每张卡之间获得间距?

我的目标是这种布局:

enter image description here

1 个答案:

答案 0 :(得分:2)

使用column布局,如下所示:

.cards {
  columns: 300px 2;
}

.cards div {
  display: inline-block;
}

或使用弹性布局:

.cards {
  display: flex;
  flex-direction: row; /* or column if you want them displayed vertically */
}
.cards div {
  flex: 1 1 auto;
}

或者,如果您只是希望它们始终显示在顶部:

.cards div {
   display: inline-block;
   vertical-align: top;
}