【发布时间】:2017-01-29 03:30:18
【问题描述】:
我在使我的 div 行居中时遇到问题,我有 3 个来自 wordpress 的帖子,相当于行内的 3 列,但是在我添加许多 css 属性使其居中后它没有居中。我也在使用wordpress。
这是我的代码:
<div class="row center-block">
<?php while ( $offerBlog->have_posts() ) : $offerBlog->the_post(); ?>
<div class="col-md-4 ">
<img src="<?php the_field('offer_image') ?>">
<br>
<br>
<h4><?php the_field('offer_title') ?></h4>
<?php the_field('offer_description') ?>
</div>
<?php endwhile; ?>
</div>
这是我的 CSS:
.col-md-4 {
width:15%;
margin:0 2.5%;
text-align: center
}
.center-block {
margin-left:auto;
margin-right:auto;
display:center;
}
【问题讨论】:
-
中心块选择器内的
text-align: center怎么样? -
display没有center值。我相信你正在寻找display: block。 -
先生有什么答案吗?
-
@JcJohn Check This 问题,希望对你有帮助。
标签: html css wordpress twitter-bootstrap