我尝试使用下面的代码以并排的方式显示网格中的帖子。但是,如图所示div显得破碎。
<?php
$args = array( 'posts_per_page' => 15, 'offset'=> 1, 'category' => '' );
$myposts = get_posts( $args );
foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
<div class="container" style="width:960px;margin :opx auo;">
<div class="colk" style="width:200px;height:150px;border-style:dotted;border-width:thin;display:inline-block;
float:left;clear:top;margin: 5px 20px 15px 0px;margin:10px;margin-top:0px;clear:top;" >
<a href="<?php the_permalink(); ?>"> <?php the_title(); echo '<br>' ?> </a>
</div>
</div>
<?php echo '<br>'; ?>
<?php endforeach; ?>
<?php
wp_reset_postdata(); ?>
如何显示div内联?
答案 0 :(得分:0)
<?php
$args = array( 'posts_per_page' => 15, 'offset'=> 1, 'category' => '' );
$myposts = get_posts( $args );?>
<div class="container" style="width:960px;margin :0 auto;">
<?php foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
<div class="colk" style="width:200px;height:150px;border-tyle:dotted;border-width:thin;display:inline-block;float:left;clear:top;margin: 5px 20px 15px 0px;margin:10px;margin-top:0px;clear:top;" >
<a href="<?php the_permalink(); ?>"> <?php the_title();?> </a>
</div>
<?php endforeach; ?>
</div>