html - 两个 md 列与 Bootstrap 的垂直对齐

标签 html css twitter-bootstrap twitter-bootstrap-3

我已经搜索并尝试了所有 Stackoverflow 解决方案,但均未成功。

我有这段代码,我正在使用 bootstrap3

<footer>
    <div class="container">
        <div class="row">
          <div class="col-md-4">
              <a href="#" target="_blank"><img src="Images/social/facebook.png" alt="facebook" class="footerimg" /></a>
              <a href="#" target="_blank"><img src="Images/social/twitter.png" alt="twitter" class="footerimg" /></a>
              <a href="#" target="_blank"><img src="Images/social/youtube.png" alt="youtube" class="footerimg" /></a>
          </div>
          <div class="col-md-4 col-md-offset-4">
              <p class="text-right">&copy; <%: DateTime.Now.Year %> Test - All Rights Reserved</p><p class="text-right">P.IVA 123456789</p>
          </div>
        </div>
    </div>
</footer>

我想将 col-md-4 元素垂直居中,并且我有这样的页脚样式:

footer {
    background-color: #000;
    color: #fff;
    height: 120px;
} 

我已经尝试将 table-cell 应用于 col-md-4 但没有成功。

你能提出一个解决方案吗?

最佳答案

如果你想要这样的东西:(图片未显示)

enter image description here

我制作了一个 live example

这是代码:

 <footer>
    <div class="container">
        <div class="row">
          <div class="col-md-4 col-sm-4">
              <div class="centered">
                  <a href="#" target="_blank"><img src="Images/social/facebook.png" alt="facebook" class="footerimg" /></a>
                  <a href="#" target="_blank"><img src="Images/social/twitter.png" alt="twitter" class="footerimg" /></a>
                  <a href="#" target="_blank"><img src="Images/social/youtube.png" alt="youtube" class="footerimg" /></a>
              </div>
          </div>
          <div class="col-md-4 col-sm-4 col-sm-offset-4 col-md-offset-4">
              <div class="centered">
                  <p class="text-right">&copy; Test - All Rights Reserved</p><p class="text-right">P.IVA 123456789</p>
              </div>
          </div>
        </div>
    </div>
</footer>

CSS

footer {
    background-color: #000;
    color: #fff;
    height: 120px;
    display: table;
    width: 100%;
}

.centered {
   display: table-cell;
   vertical-align: middle;
   height: 120px;
}

引用:centering-in-the-unknown

关于html - 两个 md 列与 Bootstrap 的垂直对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25566736/

相关文章:

jquery - 如何使用 Bootstrap 使按钮出现在中心

html - 如何将文本从textarea添加到div

javascript - 使用 javascript (jQuery) 拖动图像时出现问题

PHP:DOMDocument loadHTML 在使用 HTML5 标签时返回错误

javascript - 带有html的 slider

javascript - 如何在通过单击超链接打开 Bootstrap 模式后将值设置为 Bootstrap 模式上的文本框?

html - 使用 Bootstrap 将事件类动态添加到 Wordpress 中的自定义菜单

html - 如何在 Bootstrap 中按列而不是行对齐

twitter-bootstrap - 仅包含一个模块的 Bootstrap 样式

css - 如何获得 bootstrap v4alpha6 导航列表以证明正确?