如何在Twitter Bootstrap 3中将容器中的一个列大小的div(12列)居中.
请看起初小提琴.
.centered {
background-color: red;
}Run Code Online (Sandbox Code Playgroud)
所以,我想要一个div类.centered,在容器中居中.如果有多个div,我可以使用一行,但是现在我只想要一个在容器中居中的一列大小的div(12列).
我也不确定上述方法是否足够好,因为意图不是要抵消div一半.我不需要外面的自由空间div和div收缩比例的内容.我想将div外部空间均匀分布(缩小到容器宽度==一列).
我正在使用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
有没有办法在主要父母的内部垂直或水平居中html元素?
我希望旋转木马DIV(s7)扩展到整个屏幕的高度.我不知道它为什么没有成功.要查看该页面,您可以访问此处.
body {
height: 100%;
color: #FFF;
font: normal 28px/28px'HelveticaWorldRegular', Helvetica, Arial, Sans-Serif;
background: #222 url('') no-repeat center center fixed;
overflow: hidden;
background-size: cover;
margin: 0;
padding: 0;
}
.holder {
height: 100%;
margin: auto;
}
#s7 {
width: 100%;
height: 100%: margin: auto;
overflow: hidden;
z-index: 1;
}
#s7 #posts {
width: 100%;
min-height: 100%;
color: #FFF;
font-size: 13px;
text-align: left;
line-height: 16px;
margin: auto;
background: #AAA;
}Run Code Online (Sandbox Code Playgroud)
<div class="nav">
<a class="prev2" id="prev2" href="#">
<img src="http://static.tumblr.com/ux4v5bf/ASslogxz4/left.png">
</a> …Run Code Online (Sandbox Code Playgroud)我有一个只存在表单的页面,我希望将表单放在屏幕的中心.
<div class="container">
<div class="row justify-content-center align-items-center">
<form>
<div class="form-group">
<label for="formGroupExampleInput">Example label</label>
<input type="text" class="form-control" id="formGroupExampleInput" placeholder="Example input">
</div>
<div class="form-group">
<label for="formGroupExampleInput2">Another label</label>
<input type="text" class="form-control" id="formGroupExampleInput2" placeholder="Another input">
</div>
</form>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
该justify-content-center对齐表格水平,但我无法弄清楚如何垂直对齐.我试过使用align-items-center和align-self-center,但它不起作用.
我错过了什么?
我知道这已被问了一千次,但我找不到让文字和图像垂直居中的方法.
我正在使用带有动态内容的Twitter Bootstrap 3,因此,我不知道文本和图像的大小.另外,我希望所有这些都能做出回应.
我创建了一个bootply,总结了我想要实现的布局.基本上,我希望文本和图像垂直居中.文本并不总是比图像大.
请有人帮我解决这个问题吗?
谢谢.
我正在使用Bootstrap 4和带有图像叠加层的卡在图像上放置一些文本。文本显示在图像的顶部,而我希望它显示在底部。
这是卡的html代码:
<div class="card-deck">
{% for article in article_list|slice:":3" %}
<div class="card card-inverse align-self-center">
<div class="card-header text-center">
{{ article.category|capfirst }}
</div>
<img class="card-img" src="{% static article.image %}" alt="Card image cap">
<div class="card-img-overlay">
<h4 class="card-title">{{ article.title }}</h4>
</div>
</div>
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用Bootstrap 4的对齐帮助器类在div中垂直对齐内容“ ABC Company”。但无法做到。我正在使用以下代码。
<div class="container" style="width: 740px;">
<div class="row">
<div class="col-sm text-right" style="line-height: 20px; height: 20px; color:#004990; text-decoration:none; font-family:Helvetica, Arial, sans-serif; font-size:10px;">
Your Account
</div>
</div>
<div class="row">
<div class="col-sm text-center" style="background-color:#0471AF; height:100px;">
<span class="align-middle">ABC Company</span>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
请指出我想念的是什么!