gpt4 book ai didi

css - 在列中显示帖子

转载 作者:太空宇宙 更新时间:2023-11-04 14:27:39 26 4
gpt4 key购买 nike

我使用以下代码在两行三列中显示我的帖子:我正在使用 Bootstrap 3,并且没有更改任何会影响列的 css。

<?php   
$query_recents = new WP_Query ( array( 'post_type' => 'portfolio', 'posts_per_page' => 6, 'paged' => $paged ) );

if ( $query_recents->have_posts() ):
?>
<div class="recent-posts row">
<?php while ( $query_recents->have_posts() ) : $query_recents->the_post(); ?>
<div class="col-sm-4">
<?php get_template_part('templates/content', get_post_format()); ?>
</div>
<?php endwhile; ?>
</div>
<?php endif; ?>

这在大多数情况下都有效,除了第二行,第一个帖子被推下,如图所示。

有人可以提供有关如何纠正此问题的建议吗?提前致谢。

enter image description here

最佳答案

您将需要应用响应列重置,请参阅:http://getbootstrap.com/css/#grid-responsive-resetsBootstrap 3.0:responsive column resets section of the documentation

在你的情况下尝试:

<div class="recent-posts row">  
<?php
$i=0;
while ( $query_recents->have_posts() ) : $query_recents->the_post(); ?>
<div class="col-sm-4">
<?php get_template_part('templates/content', get_post_format()); ?>
</div>
<?php

if($i++%3==2) echo '<div class="clearfix visible-sm visible-md visible-lg"></div>';
endwhile; ?>
</div>

关于css - 在列中显示帖子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19422897/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com