如何垂直堆叠bootstrap元素

时间:2018-06-17 22:52:35

标签: html twitter-bootstrap vertical-alignment heading

我有一个标题,段落和图片,我想让它们与段落上方的标题对齐,右边的图像。当我运行它时,我得到一个水平行中的3个元素

<div class="container">
    <div class="row">
        <h1 class="col-xs-3 paddingtop">Joselin</h1>
        <p class="col-xs-3 bio">
            Growing up in the Caribbean, as a young girl Joselin worked as a
            coffee bean picker, giving her a profound insight into using only
            the freshest, and highest quality coffee beans.
        </p>
        <img class="col-xs-6 meetus" src="meetus.jpeg">    		
    </div>
</div>

1 个答案:

答案 0 :(得分:0)

如果h1应该高于pimg,那么最好将它放在自己的行中:<div class="row">。然后将pimg放在该行的正下方。

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"/>

<div class="container">
    <div class="row">
        <div class="col-xs-6">
            <h1 class="paddingtop">Joselin</h1>
            <p class="bio">
                Growing up in the Caribbean, as a young girl Joselin worked as a
                coffee bean picker, giving her a profound insight into using only
                the freshest, and highest quality coffee beans.
            </p>
        </div>
        <div class="col-xs-6">
            <img class="col-xs-6 meetus" src="meetus.jpeg">    		
        </div>
    </div>
</div>

然后你可以使用列大小(`class =“col-xs-3”)。