填充空间同位素砌体

问题描述

我想使用具有 4 列的同位素库构建砌体布局

每个项目的宽度为 25%,所有项目必须填充空白

所以我试着写下这段代码:

$('window').load(function() {
    $('.grid').isotope({
      itemSelector: '.grid-item',percentPosition: true,});
});
* { box-sizing: border-box; }

/* force scrollbar,prevents initial gap */
html {
  overflow-y: scroll; 
}

body {
  font-family: sans-serif;
}

/* ---- grid ---- */

.grid {
  background: #DDD;
}

/* clear fix */
.grid:after {
  content: '';
  display: block;
  clear: both;
}

/* ---- .element-item ---- */

/* 5 columns,percentage width */
.grid-item,.grid-sizer {
  width: calc(25% - 20px);
}

.grid-item {
  float: left;
  margin: 0 10px;
  background: #0D8;
  border: 2px solid #333;
  border-color: hsla(0,0%,0.7);
}

.grid-item div {
  padding: 15px;
}

.grid-item--width2 { width: 40%; }
.grid-item--height2 { height: 200px; }
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://unpkg.com/isotope-layout@3/dist/isotope.pkgd.js"></script>

<h1>Isotope - masonry fluid sizing</h1>

<div class="grid">
  <div class="grid-sizer"></div>
  <div class="grid-item"><div>loreloremlorem loremloremlorem loremlorem loremloremlore mloremloremlore mloremloremm</div></div>
                        <div class="grid-item"><div>loremvloremlor emloremlo rem</div></div>
                        <div class="grid-item"><div>loremloremlore mloremloremlor emloremloremloreml oremlorem</div></div>
                        <div class="grid-item"><div>loremlore mloremlore mloremlorem</div></div>
                        <div class="grid-item"><div>loremloreml oremloremloremlo remloremloremloreml oremloremlo remlore mloremlore mlorem</div></div>
                        <div class="grid-item"><div>lore mloremloremloreml oremloremlore mloremlorem</div></div>
                        <div class="grid-item"><div>loreml orem</div></div>
                        <div class="grid-item"><div>loremlore mloremlor emloremloreml oremloreml oremlorem</div></div>
                        <div class="grid-item"><div>loremlor emloremlor emlorem lorem</div></div>
</div>

如您所见,空白未填充,项目之间存在巨大差距 我希望我的物品彼此靠近

感谢您的帮助!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...