【问题标题】:Creating a Masonry grid in wordpress在 wordpress 中创建砌体网格
【发布时间】:2019-05-10 14:38:15
【问题描述】:

我希望在我的网站主页上实现一个砖石网格,其中包含 4 张图片。

有 2 个矩形图像和 2 个方形图像,但我想将它们放在一起,以便它们适合一个漂亮的网格。

我在下面附上了一张图片给你看。

我正在使用 WPBakery 页面构建器在 Wordpress 中构建我的网站,但我似乎无法找到一种方法来实现我正在寻找的东西。

还有其他插件可以帮助我吗? 我实现这一目标的最佳方式是什么?

谢谢

【问题讨论】:

    标签: wordpress grid wpbakery


    【解决方案1】:

    试试 CSS 网格,它会给你这个:

    .wrapper {
        display: grid;
        grid-gap: 10px;
            grid-template-columns: 200px 200px 200px;
            grid-template-rows: 200px 200px 200px;
            background-color: #fff;
            color: #444;
    }
    
    .box {
        background: none;
        border-radius: 5px;
        padding: 20px;
        font-size: 150%;
    }
    
    .a {
        background-image: url(http://placehold.it/200x400);
        grid-column: 1;
    		grid-row: 1/3;
    	}
    
    .b {
        background-image: url(http://placehold.it/400x200);
        grid-column:  2 / span 2;
        grid-row: 1;
    }
    
    .c {
        background-image: url(http://placehold.it/200x200);
        grid-column: 2;
        grid-row: 2;
     }
    
     .d {
        background-image: url(http://placehold.it/200x200);
        grid-column: 3;
        grid-row: 2;
    }
    <div class="wrapper">
          <div class="box a">A</div>
          <div class="box b">B</div>
          <div class="box c">C</div>
          <div class="box d">D</div>
        </div>

    【讨论】:

    • 谢谢!我将尝试这个解决方案,因为我可以将自定义 HTML/CSS 添加到 wordpress 页面
    • 此解决方案适用于 Chrome、Edge 和 Safari,但不适用于 IE11。它没有使用网格,而是将内容堆叠在一起,将盒子放在彼此下方的 4 个单独的行中。它可能在网格属性中?我怎样才能解决这个问题?它几乎是旧浏览器的游戏破坏者
    • Edge 是 MS 的新浏览器,完全支持 display: grid。如果要支持 IE,则需要添加自己的 CSS。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-22
    相关资源
    最近更新 更多