所以我需要为画廊制作均匀间隔的元素,但显然是1vw = / = 2 * 0.5vw



.galeriacontainer {
  position: absolute;
  width: 80vw;
  max-width: 80vw;
  height: 75vh;
  max-height: 75vh;
  background-color: rgba(20, 20, 20, 0.4);
  left: 10vw;
  top: 12.5vh;
}
.itemframe {
  width: 19vw;
  max-width: 19vw;
  height: 24vh;
  max-height: 24vh;
  margin-left: 0.5vw;
  margin-top: 0.5vh;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.2);
  float: left;
  overflow: hidden;
}

<div class="galeriacontainer">
  <div class="itemframe">&nbsp;</div><div class="itemframe">&nbsp;</div><div class="itemframe">&nbsp;</div><div class="itemframe">&nbsp;</div>
  <div class="itemframe">&nbsp;</div><div class="itemframe">&nbsp;</div><div class="itemframe">&nbsp;</div><div class="itemframe">&nbsp;</div>
  <div class="itemframe">&nbsp;</div><div class="itemframe">&nbsp;</div><div class="itemframe">&nbsp;</div><div class="itemframe">&nbsp;</div>
</div>





所以图库容器是80vw,所以如果我要均匀地间隔4个div,我会做80/4 = 20、20-1 = 19、1 / 2 = 0.5,对吗?我不明白为什么它显示得如此奇怪。

编辑:我的问题是如何使其表现出应有的方式

最佳答案

这似乎是合理的,但它不是一个很好的解决方案,只是大小和边距都经过微调。



.galeriacontainer {
  position: absolute;
  width: 80vw;
  max-width: 80vw;
  height: 75vh;
  max-height: 75vh;
  margin: 0;
  padding: 0;
  background-color: rgba(20, 20, 20, 0.4);
  left: 10vw;
  top: 12.5vh;
}
.itemframe {
  width: 19.25vw;
  height: 23.75vh;
  margin-left: 0.6vw;
  margin-top: 0.95vh;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.2);
  float: left;
  overflow: hidden;
}

<div class="galeriacontainer">
  <div class="itemframe">&nbsp;</div>
  <div class="itemframe">&nbsp;</div>
  <div class="itemframe">&nbsp;</div>
  <div class="itemframe">&nbsp;</div>
  <div class="itemframe">&nbsp;</div>
  <div class="itemframe">&nbsp;</div>
  <div class="itemframe">&nbsp;</div>
  <div class="itemframe">&nbsp;</div>
  <div class="itemframe">&nbsp;</div>
  <div class="itemframe">&nbsp;</div>
  <div class="itemframe">&nbsp;</div>
  <div class="itemframe">&nbsp;</div>
</div>

07-28 05:03