我正在使用Twitter Bootstrap 3,当我想垂直对齐时我遇到问题div,例如 - JSFiddle链接:
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<div class="row">
<div class="col-xs-5">
<div style="height:5em;border:1px solid #000">Big</div>
</div>
<div class="col-xs-5">
<div style="height:3em;border:1px solid #F00">Small</div>
</div>
</div>Run Code Online (Sandbox Code Playgroud)
Bootstrap中的网格系统float: left不使用display:inline-block,因此该属性vertical-align不起作用.我尝试使用margin-top它来修复它,但我认为这对于响应式设计来说不是一个好的解决方案.
我正在寻找一种垂直居中对齐containerdiv的方法,jumbotron并将其设置在页面中间.
在.jumbotron必须适应屏幕的整个高度和宽度,所以我用这个CSS.
.jumbotron {
height:100%;
width:100%;
}
.container {
width:1025px;
}
.jumbotron .container {
max-width: 100%;
} Run Code Online (Sandbox Code Playgroud)
的.containerdiv有一个宽度1025px和应在该页面(垂直中心)的中间.
<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 …Run Code Online (Sandbox Code Playgroud) html css vertical-alignment twitter-bootstrap twitter-bootstrap-3
我知道这已被问了一千次,但我找不到让文字和图像垂直居中的方法.
我正在使用带有动态内容的Twitter Bootstrap 3,因此,我不知道文本和图像的大小.另外,我希望所有这些都能做出回应.
我创建了一个bootply,总结了我想要实现的布局.基本上,我希望文本和图像垂直居中.文本并不总是比图像大.
请有人帮我解决这个问题吗?
谢谢.