我在col中有一个文本,我想知道如何将此文本放在col的中间。
<div class="container-fluid">
<div class="row">
<div class="col-xs-2 "><img src="images/header/picture.png" alt="Menu"></div>
<div class="col-xs-7 ">Perfile</div>
<div class="col-xs-3"><img src="images/header/picture.png" alt="Menu"></div>
</div>
答案 0 :(得分:0)
试试这个。
Perfile
答案 1 :(得分:0)
我有四种解决方案。第一个要求图像高度相同。在另外三个图像中,图像的高度可能不同。
您可以为文字设置属性line-height
。 line-height
必须等于图像的高度。当文本占据一行并且图像具有相同的高度时,它是合适的。
.put-in-the-middle {
line-height: 80px; /* = height of the picture.png */
}
&#13;
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<div class="container-fluid">
<div class="row">
<div class="pull-left"><img src="http://placehold.it/80x80/69c/fff/" alt="Menu"></div>
<div class="pull-right"><img src="http://placehold.it/120x80/9c6/fff/" alt="Menu"></div>
<div class="put-in-the-middle text-center">Perfile</div>
</div>
</div>
&#13;
您可以转换表格单元格中的块。然后将vertical-align: middle;
应用于他们。
.transform-in-a-table {
display: table;
}
.transform-in-a-table div {
display: table-cell !important;
vertical-align: middle;
}
.make-it-wide {
width: 100%;
}
&#13;
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<div class="container-fluid">
<div class="row transform-in-a-table">
<div><img src="http://placehold.it/80x40/c69/fff/" alt="Menu"></div>
<div class="make-it-wide text-center">Perfile</div>
<div><img src="http://placehold.it/120x80/9c6/fff/" alt="Menu"></div>
</div>
</div>
&#13;
.make-it-wide {
width: 100%;
}
&#13;
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<table>
<tr>
<td><img src="http://placehold.it/80x40/c69/fff/" alt="Menu"></td>
<td class="make-it-wide text-center">Perfile</td>
<td><img src="http://placehold.it/120x80/9c6/fff/" alt="Menu"></td>
</tr>
</table>
&#13;
您可以使用vertical-align with Bootstrap 3中包含属性text-align-last的想法。
.vertical-middle {
text-align-last: justify;
}
.vertical-middle > div,
.vertical-middle > img {
display: inline-block;
vertical-align: middle;
}
&#13;
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<div class="container-fluid">
<div class="row vertical-middle">
<img src="http://placehold.it/80x40/c69/fff/" alt="Menu">
<div>Perfile</div>
<img src="http://placehold.it/120x80/9c6/fff/" alt="Menu">
</div>
</div>
&#13;
答案 2 :(得分:0)
您可以使用引导类text-center
将元素置于列
<div class="container-fluid">
<div class="row">
<div class="col-xs-2 "><img src="images/header/picture.png" alt="Menu"></div>
<div class="col-xs-7 text-center">Perfile</div>
<div class="col-xs-3"><img src="images/header/picture.png" alt="Menu"></div>
</div>