【问题标题】:How can I add a fixed width to this mansory grid如何向这个砌体网格添加固定宽度
【发布时间】:2018-11-08 04:44:50
【问题描述】:

我使用 mansonry.js 有非常相似的布局

https://codepen.io/anon/pen/KrVGox

但我无法理解如何制作固定宽度为 1000 像素的网格

.grid {
  background: red;
  /* center */
  margin: 0 auto;
  max-width: 1000px;
}

添加最大宽度:1000px;打破网格项目以脱离网格或添加宽度:1000px;什么都不做。

【问题讨论】:

    标签: javascript masonry


    【解决方案1】:

    你可以试试这个,

    CSS 底部边距

    .grid-item {
        width: 160px;
        height: 120px;
        float: left;
        /* vertical gutter */
        margin-bottom: 20px;
        background: #D26;
        border: 2px solid #333;
        border-color: hsla(0, 0%, 0%, 0.5);
        border-radius: 5px;
    }
    

    JS

    $('.grid').masonry({
        itemSelector: '.grid-item',
        columnWidth: 160,
        gutter: 20
    });
    

    【讨论】:

    • 但是如何从 masonry.js 中保留 fitWidth: true 的特性,它允许在移动项目时将网格项目居中
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-10
    • 2021-10-29
    相关资源
    最近更新 更多