【发布时间】:2014-04-07 10:36:42
【问题描述】:
我正在寻找一种将container div 垂直居中在jumbotron 内并将其设置在页面中间的方法。
.jumbotron 必须适应屏幕的整个高度和宽度。 .container div 的宽度为 1025px,应位于页面中间(垂直居中)。
我希望此页面使 jumbotron 适应屏幕的高度和宽度,同时容器垂直居中于 jumbotron。我怎样才能实现它?
.jumbotron {
height:100%;
width:100%;
}
.container {
width:1025px;
}
.jumbotron .container {
max-width: 100%;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="jumbotron">
<div class="container text-center">
<h1>The easiest and powerful way</h1>
<div class="row">
<div class="col-md-7">
<div class="top-bg"></div>
</div>
<div class="col-md-5 iPhone-features" style="margin-left:-25px;">
<ul class="top-features">
<li>
<span><i class="fa fa-random simple_bg top-features-bg"></i></span>
<p><strong>Redirect</strong><br>Visitors where they converts more.</p>
</li>
<li>
<span><i class="fa fa-cogs simple_bg top-features-bg"></i></span>
<p><strong>Track</strong><br>Views, Clicks and Conversions.</p>
</li>
<li>
<span><i class="fa fa-check simple_bg top-features-bg"></i></span>
<p><strong>Check</strong><br>Constantly the status of your links.</p>
</li>
<li>
<span><i class="fa fa-users simple_bg top-features-bg"></i></span>
<p><strong>Collaborate</strong><br>With Customers, Partners and Co-Workers.</p>
</li>
<a href="pricing-and-signup.html" class="btn-primary btn h2 lightBlue get-Started-btn">GET STARTED</a>
<h6 class="get-Started-sub-btn">FREE VERSION AVAILABLE!</h6>
</ul>
</div>
</div>
</div>
</div>
【问题讨论】:
-
在响应式居中列上查看此内容minimit.com/articles/solutions-tutorials/…
-
css-vertical-center.com有一些带有浏览器兼容性信息的解决方案
-
未来的读者使用 Bootstrap 4 和 Bootstrap 5 see this question
标签: html css twitter-bootstrap twitter-bootstrap-3 vertical-alignment