开发者

Vertical alignment of DIV's using relative positioning and inline-block?

开发者 https://www.devze.com 2023-04-04 08:57 出处:网络
I have a problem aligning DIV\'s vertically, when the contents within them have different height (although the DIV\'s themselves have a fixed size).

I have a problem aligning DIV's vertically, when the contents within them have different height (although the DIV's themselves have a fixed size).

See HTML example here 开发者_运维知识库(with inline CSS)

I want the DIV's to "flow" like text, so I'd like to avoid using position:absolute if possible. I'm using display: inline-block to the DIV's won't collapse.


Add a vertical-align property - it doesn't matter which one, they all do the same thing, since they're the same size. If they're different sizes, use vertical-align: middle:

.collection_box {
    vertical-align: middle; /* or top, or bottom, if they're the same size */
}


Float them to the left:

.collection_box {
  float: left;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号