twitter-bootstrap - Bootstrap 垂直对齐属性不起作用

标签 twitter-bootstrap bootstrap-4 vertical-alignment

Bootstrap 文档中的一个非常基本的问题。到目前为止,一切似乎都正常,除了这个垂直对齐。在下图中,您可以看到 How it should beHow it appears in my browser .

   <div class="container">
      <div class="row">
        <div class="col align-self-start">
          One of three columns
        </div>
        <div class="col align-self-center">
          One of three columns
        </div>
        <div class="col align-self-end">
          One of three columns
        </div>
      </div>
   </div>

最佳答案

垂直中心相对于高度。在您的示例中,所有同级列的高度都相同,因此您不会看到任何对齐方式的变化。

.row 需要定义高度,列中的某些内容导致行具有更高的高度。

<div class="container">
    <div class="row" style="height:180px">
        <div class="col align-self-start">
            One of three columns
        </div>
        <div class="col align-self-center">
            One of three columns
        </div>
        <div class="col align-self-end">
            One of three columns
        </div>
    </div>
</div>

演示:https://www.codeply.com/go/aCGgDtzhdY

关于twitter-bootstrap - Bootstrap 垂直对齐属性不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50657084/

相关文章:

latex - 标题页垂直居中

html - Bootstrap 4 : responsive pictures + cropping?

html - 如何使 SVG 宽度响应但保持 SVG 高度不变?

javascript - 单击提交按钮时突然禁用

jquery - 在调整传单 map 的高度时在 Bootstrap 4 中显示/隐藏 div

jquery - 始终采用第一个元素 id。如何重置事件并实际获取元素

html - 将文本垂直对齐到我的列 div 的中间

html - div 中的垂直对齐图像

javascript - Bootstrap Modal - 使用 Javascript 将数据传递到 Modal

jquery - 在 bootstrap 幻灯片中抓取 Twitter 提要