Bootstrap布局嵌套?

时间:2016-12-09 04:12:18

标签: html css twitter-bootstrap-3

我对bootstrap相当新,并且在嵌套方面遇到了麻烦。我有一个我正在尝试重新创建的布局而没有在此处看到正确的结果layout image

我的代码http://www.bootply.com/0BETlZMU7T

var name = "Waleed";
var message = `Hello ${name}!`;

1 个答案:

答案 0 :(得分:0)

默认引导程序无法进行垂直对齐,但您可以使用此解决方案中显示的代码来实现 vertical-align with Bootstrap 3

您的updatetd html如下所示:

<div class="container-fluid">
    <div class="row">
        <div class="col-md-4">image with image text here</div>
        <div class="col-md-8">
            <div class="row">
                <div class="col-md-6">A Text</div>
                <div class="col-md-6">B Text</div>
            </div>
            <div class="row">
                <div class="col-md-6">Y Text</div>
                <div class="col-md-6">Z Text</div>
            </div>
        </div>
    </div>
</div>

你的CSS喜欢:

/*From: 
  https://stackoverflow.com/questions/20547819/vertical-align-with-bootstrap-3#answer-25517025
*/
.vertical-align {
  display: flex;
  flex-direction: row;
}

.vertical-align > [class^="col-"],
.vertical-align > [class*=" col-"] {
  display: flex;
  align-items: center;
  justify-content: center; /* Optional, to align inner items 
                              horizontally inside the column */
}

/**
 *  "flex: 1" or "flex-grow: 1" is added to make the inner div
 *  - Which is also a flex-item - take up all the horizontal space
 *  available space inside the flex container (.col-* elements)
 */
.vertical-align > [class^="col-"] > div,
.vertical-align > [class*=" col-"] > div {
  /* flex: 1; */
  flex-grow: 1;
}

我用你的代码给你做了一个例子,我把项目“A,B,X,Y”合并成一行,因为你不需要第二行。

http://www.bootply.com/uIVbiDLGkj