如何保持列中div的距离相等?

问题描述 投票:0回答:1

如何保持 div 彼此之间的距离相等,就像它们周围有空间一样,但以列的方式。

喜欢

div 1

div 2

div 3

一个在另一个下面

html css ejs
1个回答
0
投票

我们可以将它们放入 div 容器中,然后使用 flex,如下所示:

<div class="container">
        <div>1</div>
        <div>2</div>
        <div>3</div>
</div>

.container {
   display: flex;
   flex-direction: column;
   height: 200px;
   justify-content: space-between;
}
© www.soinside.com 2019 - 2024. All rights reserved.