如何使用css并排对齐p标签?

时间:2015-04-17 15:43:49

标签: html css

我目前在将div中的p标签并排放置时遇到问题,这是我的代码: -

<div class="div_right">
<div style="background-color: #EEEEF1; width:300px; padding:20px 30px;">
<p><img class="_51sw img" alt="" src="https://www.facebook.com/images/profile/timeline/app_icons/info_24.png" alt="SJT" title="SJT"> About <?php echo $name; ?></p><hr>
<p style="font-weight:bold;">Tagline</p>
<?php echo $tagline; ?>
<p style="font-weight:bold;">School</p>
<?php echo $school; ?>
<p style="font-weight:bold;">Core Commitee Member</p>
<?php echo $member; ?>
<p style="font-weight:bold;">Bragging Rights/Achievements</p>
<?php echo $brag; ?>

</div>

但是我想将标语和学校并排放在一栏中,而在另一栏中,将核心委员会和吹牛的权利并排放在一起,我不知道该怎么做。

2 个答案:

答案 0 :(得分:1)

您只需使用display:table-cell包含所有<p>元素即可实现:

p {
    display: table-cell;
}
<div style="background-color: #EEEEF1; width:3000px; padding:20px 30px;">
<p><img class="_51sw img" alt="" src="https://www.facebook.com/images/profile/timeline/app_icons/info_24.png" alt="SJT" title="SJT"> About <?php echo $name; ?></p><hr>
<p style="font-weight:bold;">Tagline</p>
<?php echo $tagline; ?>
<p style="font-weight:bold;">School</p>
<?php echo $school; ?>
<p style="font-weight:bold;">Core Commitee Member</p>
<?php echo $member; ?>
<p style="font-weight:bold;">Bragging Rights/Achievements</p>
<?php echo $brag; ?>

</div>

答案 1 :(得分:0)

将您的DIV设置为将其显示为表格或表格行。然后每个

应该显示为一个表格cell.can都可以在css中完成,类​​会有所帮助!