【问题标题】:Bulma overlapping items布尔玛重叠项目
【发布时间】:2017-08-24 12:19:46
【问题描述】:

我正在使用bulma.css 进行布局,但是当我给某个东西添加边框时,我发现它重叠了。

这里是重叠:

.shop div 似乎“符合预期”

但是 .basket div 似乎有点爬升了。

Here is a link to a demo

还有HTML:

<div id="app">
  <div class="container">
    <div class="shop">
      <div class="columns">
        <div class="column is-one-quarter product">
          <h3 class="title is-4">Cat</h3>
          <p>
            £<span>2.99</span></p>
          <div><button class="button">Add to basket</button></div>
        </div>
        <div class="column is-one-quarter product">
          <h3 class="title is-4">Dog</h3>
          <p>
            £<span>4.00</span></p>
          <div><button class="button">Add to basket</button></div>
        </div>
      </div>
    </div>
    <div class="basket">
      <h1>Basket</h1>
      <table class="table">
        <thead>
          <tr>
            <td>Item</td>
            <td>Quantity</td>
            <td>Price</td>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td colspan="3">No items in the basket</td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</div>

CSS:

// All of bulma.css
html,body{
  height:100%;
  padding:20px;
}

.product{
  box-sizing:border-box;
  border:2px solid #eaeaea;
  padding:20px;
}

我认为这与 ... flexbox 有关?我不确定!

【问题讨论】:

    标签: html css bulma


    【解决方案1】:

    在它的最新版本中尝试 is-gapless 以及列类

    【讨论】:

      【解决方案2】:

      由于 Bulma 代码中的这条规则,底部容器正在爬上顶部容器:

      .columns:last-child {
          margin-bottom: -.75rem;
      }
      

      只需覆盖它。将此添加到您的代码中:

      .columns:last-child {
          margin-bottom: 0 !important;
      }
      

      !important 可能不是必需的。我只是添加它以确保您的规则占上风。

      【讨论】:

      • 感谢您的指点。这就是它发生的方式,但是我发现了原因。 .column 上的填充,.columns 内的填充抵消了这个负边距。所以答案是将我的.product div 放在列中,而不是意外覆盖.column 样式。 github.com/jgthms/bulma/issues/1047
      猜你喜欢
      • 1970-01-01
      • 2020-09-10
      • 1970-01-01
      • 2020-07-11
      • 1970-01-01
      • 1970-01-01
      • 2018-05-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多