CSS:删除框之间的空白

CSS:删除框之间的空白,css,flexbox,Css,Flexbox,我有一个灵活的布局(不确定这是否正确)和不同大小的内容框。我可以定义宽度,但高度是可变的。如果我有很多大小不等的盒子,那么内容较少的盒子就会有很多空白。填补这个空白对我来说很重要。你知道我怎样才能摆脱空位吗 见示例: JS-Bin .部分{ 宽度:40%; xheight:200px; } 1 Lorem Ipsum只是印刷和排版行业的虚拟文本。 Lorem Ipsum只是印刷和排版行业的虚拟文本。从16世纪开始,一个不知名的印刷商开始制作一本活字样本书。它不仅存活了五个世纪,而且还跨越到电子

我有一个灵活的布局(不确定这是否正确)和不同大小的内容框。我可以定义宽度,但高度是可变的。如果我有很多大小不等的盒子,那么内容较少的盒子就会有很多空白。填补这个空白对我来说很重要。你知道我怎样才能摆脱空位吗

见示例:


JS-Bin
.部分{
宽度:40%;
xheight:200px;
}
1 Lorem Ipsum只是印刷和排版行业的虚拟文本。
Lorem Ipsum只是印刷和排版行业的虚拟文本。从16世纪开始,一个不知名的印刷商开始制作一本活字样本书。它不仅存活了五个世纪,而且还跨越到电子排版,基本上保持不变。它在20世纪60年代随着包含Lorem Ipsum段落的Letraset表单的发布而流行,最近随着Aldus PageMaker等桌面出版软件的发布,包括Lorem Ipsum版本。
3印刷和排版行业的虚拟文本。自16世纪以来,Lorem Ipsum一直是行业标准的虚拟文本,当时一位不知名的印刷商拿起一个打印工具,将其拼凑成一本打印样本书。它不仅存活了五个世纪,而且还跨越到电子排版,基本上保持不变。它在20世纪60年代随着包含Lorem Ipsum段落的Letraset表单的发布而流行,最近随着Aldus PageMaker等桌面出版软件的发布,包括Lorem Ipsum版本。
4自16世纪以来,行业标准的虚拟文本,当时一位不知名的印刷商拿着一个铅字厨房,将其拼凑成一本铅字样本书。它不仅存活了五个世纪,而且还跨越到电子排版,基本上保持不变。它在20世纪60年代随着包含Lorem Ipsum段落的Letraset表单的发布而流行,最近随着Aldus PageMaker等桌面出版软件的发布,包括Lorem Ipsum版本。
5 Lorem Ipsum只是印刷和排版行业的虚拟文本。自16世纪以来,Lorem Ipsum一直是行业标准的虚拟文本,当时一位不知名的印刷商拿起一个打印工具,将其拼凑成一本打印样本书。它不仅存活了五个世纪,而且还跨越到电子排版,基本上保持不变。它在20世纪60年代随着包含Lorem Ipsum段落的Letraset表单的发布而流行,最近随着Aldus PageMaker等桌面出版软件的发布,包括Lorem Ipsum版本。

终于找到了“砖石”这个神奇的词。 这里是线程:

还有另一种方法:

类似的方法


JS-Bin
.包装纸{
列数:3;
柱间距:1.25雷姆;
}
.部分{
内破:避开立柱;
位置:相对位置;
显示:内联块;
宽度:100%;
-网络工具包盒方向:垂直;
-webkit盒方向:正常;
弯曲方向:立柱;
}
1 Lorem Ipsum只是印刷和排版行业的虚拟文本。
Lorem Ipsum只是印刷和排版行业的虚拟文本。从16世纪开始,一个不知名的印刷商开始制作一本活字样本书。它不仅存活了五个世纪,而且还跨越到电子排版,基本上保持不变。它在20世纪60年代随着包含Lorem Ipsum段落的Letraset表单的发布而流行,最近随着Aldus PageMaker等桌面出版软件的发布,包括Lorem Ipsum版本。
3印刷和排版行业的虚拟文本。自16世纪以来,Lorem Ipsum一直是行业标准的虚拟文本,当时一位不知名的印刷商拿起一个打印工具,将其拼凑成一本打印样本书。它不仅存活了五个世纪,而且还跨越到电子排版,基本上保持不变。它在20世纪60年代随着包含Lorem Ipsum段落的Letraset表单的发布而流行,最近随着Aldus PageMaker等桌面出版软件的发布,包括Lorem Ipsum版本。
4自16世纪以来,行业标准的虚拟文本,当时一位不知名的印刷商拿着一个铅字厨房,将其拼凑成一本铅字样本书。它不仅存活了五个世纪,而且还跨越到电子排版,基本上保持不变。它在20世纪60年代随着包含Lorem Ipsum段落的Letraset表单的发布而流行,最近随着Aldus PageMaker等桌面出版软件的发布,包括Lorem Ipsum版本。
5 Lorem Ipsum只是印刷和排版行业的虚拟文本。自16世纪以来,Lorem Ipsum一直是行业标准的虚拟文本,当时一位不知名的印刷商拿起一个打印工具,将其拼凑成一本打印样本书。它不仅存活了五个世纪,而且还跨越到电子排版,基本上保持不变。它在20世纪60年代随着包含Lorem Ipsum段落的Letraset表单的发布而流行,最近随着Aldus PageMaker等桌面出版软件的发布,包括Lorem Ipsum版本。

flex无法做到这一点,但列CSS可以做到:如果您告诉每个元素要放在哪里,则可能会一列接一列地填充网格,但需要知道它们有多大……您不应该这样定义固定宽度。试试
fr
装置
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  <style>
    .part {
      width: 40%;
      xheight: 200px;
    }
  </style>
</head>
<body>

  <div class="d-flex flex-wrap" style="height:100%; width:100%;">
    <div class="part p-3">1 Lorem Ipsum is simply dummy text of the printing and typesetting industry.</div>
    <div class="part p-3">2 Lorem Ipsum is simply dummy text of the printing and typesetting industry. t ever since the 1500s, when an unknown printer took a o make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</div>
    <div class="part p-3">3 dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</div>
    <div class="part p-3">4 industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</div>
    <div class="part p-3">5 Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</div>
  </div>
</body>
</html>