Bootstrap 砌体网格(从左到右)

yrdbyhpb  于 2022-12-07  发布在  Bootstrap
关注(0)|答案(2)|浏览(134)

你好,我正在使用引导砖石网格,它在WordPress的循环显示后。目前的职位显示从上到下。我想显示他们从左到右。我已经尝试了一些东西,但网格得到干扰。任何解决方案与css将是好的。

<div class="item blogGridBox">
        <div class="well well-sm">
            <h3 class="special-blog-title truncate"><a href="<?php the_permalink() ?>"><?php the_title() ?></a></h3>
            <span class="special-blog-author">By: <?php the_author_meta( 'display_name' ); ?></span><span class="special-blog-date">| <?php echo get_the_date(); ?></span>
            <span class="special-blog-comments disqus-comment-count" data-disqus-url="<?php the_permalink() ?>#disqus_thread"></span>
            <a href="<?php the_permalink() ?>">
            <?php if ( has_post_thumbnail() ) { 
                the_post_thumbnail('full', array( 'class' => 'center-block img-responsive' ));  
            }
            else
            {
            ?>
            <img src="<?php echo get_template_directory_uri(); ?>/images/xoomthumb.png" alt="Xoomworks" class="img-responsive center-block" /> <?php
            }
            ?>
            </a>
            <?php the_excerpt() ?>
            <a href="<?php the_permalink() ?>" class="special-blog-more">Read More</a>
         </div>
    </div>

下面是CSS

.container.blogGap .item{
    display: inline-block;
    padding: 0.25rem;
    width: 100%;
}
.special-blog{
    max-height: 26px;    
}

.container.blogGap .row {
     -moz-column-width: 25em;
     -webkit-column-width: 25em;
     -moz-column-gap: 1em;
     -webkit-column-gap:1em;
}
.container.blogGap .well {
    border: medium none;
    box-shadow: none;
    display: block;
    margin-bottom: 40px;
    background-color:#FFF;
    position: relative;
    border-radius: 8px;
    padding-bottom: 17px;
    padding:12px;
}

.container .special-blog-title, .container .special-blog-title a{
    color: #5c5c5c !important;
    font-size: 20px;
    margin-bottom: 25px;
    line-height: 23px;
    margin-top: 6px;
}
.container .special-blog-author{color: #136eb7; padding-right: 5px; font-size: 13px; margin-bottom: 10px; display: inline-table;}
.container .special-blog-date{color: #8b8b8b; padding-right: 5px; font-size: 13px; margin-bottom: 10px; display: inline-table;}
.container .special-blog-comments{color: #136eb7; float: right; font-size: 13px; margin-bottom: 10px; display: inline-table;}
.container .special-blog-content{ font-size: 15px; line-height: 20px;margin: 19px 0 10px; display: inline-table;}
.container .special-blog-more{color: #136eb7;font-size: 14px; text-decoration: none; display: inline-table;}
.container .special-blog-more:hover{color: #136eb7;text-decoration: none; display: inline-table;}
.container .special-blog-more:focus{color: #136eb7;text-decoration: none; display: inline-table;}
.container .special-blog-more:selected{color: #136eb7;text-decoration: none; display: inline-table;}
.item.blogGridBox p{     color: #777;font-size: 16px;line-height: 1.55;margin: 19px 0 10px; display: inline-table;}
tv6aics1

tv6aics11#

我认为回答你的问题在最容易理解的方式是访问以下网站isotope masonry我用它为我所有的梅森要求与 Bootstrap .希望这有帮助.干杯

5t7ly7z5

5t7ly7z52#

Bootstrap 5 points to Desandro的砖石解决方案可供选择。
这在Bootstrap 4中也适用于我。
包括脚本:

<script src="https://cdn.jsdelivr.net/npm/masonry-layout@4.2.2/dist/masonry.pkgd.min.js" integrity="sha384-GNFwBvfVxBkLMJpYMOABq3c+d3KnQxudP/mGPkzpZSTYykLBNsZEnG2D9G/X/+7D" crossorigin="anonymous" async></script>

然后,将data-masonry='{"percentPosition": true }'加入至. row Package 函数。
这适用于等间距的列,我还让它适用于col-6和col-3元素,但不适用于col-7和col-5;在后一种情况下,只是堆叠列。

相关问题