简体   繁体   English

如何使用引导程序在中间获取div内容

[英]how to get div content in middle using bootstrap

在此处输入图片说明 I have 3 divs in a row, I need 3 divs should be aligned in the center. 我连续有3个div,我需要在中心对齐3个div。

<div class="row">
  <div class="center">
    <div class="col-sm-4" id="ph-container"></div>
    <div class="col-sm-4" id="do-container"></div>
    <div class="col-sm-4" id="water-temperature-container"></div>
  </div>
</div>

Use text-center instead of center . 使用text-center而不是center

<div class="row">
  <div class="text-center">
    <div class="col-sm-4 col-sm-offset-1" id="ph-container"></div>
    <div class="col-sm-4" id="do-container"></div>
    <div class="col-sm-4" id="water-temperature-container"></div>
  </div>
</div>

Adding an offset will help you in making the view better. 添加偏移量将帮助您改善视图。

<div class="row">
    <div class="col-sm-offset-1 col-sm-3" id="ph-container"></div>
    <div class="col-sm-3" id="do-container"></div>
    <div class="col-sm-3" id="water-temperature-container"></div>
</div>

This makes the three divs slightly narrower, and pushes them from the left, making them appear in the centre of the page. 这会使三个div稍微变窄,并将它们从左侧推入,使其显示在页面的中央。

Bear in mind, by making the divs narrower, your graphs may not look correct, so you'll need to correct your styling to adapt into the new div sizes. 请记住,通过使div变窄,您的图形可能看起来不正确,因此您需要更正样式以适应新的div大小。

This might help you actually: Bootstrap 3 1.5 column offset 这实际上可以为您提供帮助: Bootstrap 3 1.5列偏移量

the total number of cols is 12, if you use 12 cols (4+4+4=12) it will be not in center cose they wil be take all with of parent block. cols的总数为12,如果您使用12 cols(4 + 4 + 4 = 12),它将不在中间,因为它们将全部与父块一起使用。 So you must use less cols 因此,您必须使用更少的cols

<div class="row">
    <div class="col-sm-pull-1 col-sm-3" id="ph-container"></div>
    <div class="col-sm-3" id="do-container"></div>
    <div class="col-sm-3" id="water-temperature-container"></div>
</div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM