Center align vertically the container in bootstrap
This is the answer to "How to center align vertically the container in bootstrap" on Stackoverflow: http://stackoverflow.com/questions/22196587/how-to-center-align-vertically-the-container-in-bootstrap
by Avi Algaly
HTML
<link rel="stylesheet" href="http://getbootstrap.com/dist/css/bootstrap.css">
<div class="header"></div>
<div class="jumbotron vertical-center">
<div class="container text-center">
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 xxx" style="height:360px;width:374px;position:relative;">
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 xxx">
<h3>Welcome! Please Sign-In</h3>
</div>
</div>
<div class="row xxx">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="xxx">
<input type="text"/>
</div>
</div>
</div>
<div class="row xxx1">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 xxx2">
<button>Sign In</button>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 xxx" style="height:360px;width:374px;">
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 xxx"><h3> </h3></div>
</div>
<div class="row ">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 xxx ">
<img src="https://placeholdit.imgix.net/~text?txtsize=10&txt=Controll%20Up&w=232&h=277 " />
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="footer footer-static ">Footer</div>
CSS
.xxx {
border:solid 1px lime;
}
.xxx1 {
background-color:green;
height:76px;
position:absolute;
bottom:0;
width:100%;
}
.header {
width:100%;
height:126px;
background: transparent url(https://placeholdit.imgix.net/~text?txtsize=10&txt=Controll%20Up&w=236&h=34) no-repeat 30px 26px;
}
.footer {
width: 100%;
height: 50px;
background-color: #999;
color: #fff;
transition: all 0.5s ease;
position: fixed;
bottom: 0;
}
.footer-static {
height:50px;
position:relative;
transition: all 0.5s ease;
}
.jumbotron.vertical-center {
margin-bottom: 0;
/* Remove the default bottom margin of .jumbotron */
}
.vertical-center {
min-height: 100%;
/* Fallback for vh unit */
min-height: 100vh;
/* You might also want to use
'height' property instead.
Note that for percentage values of
'height' or 'min-height' properties,
the 'height' of the parent element
should be specified explicitly.
In this case the parent of '.vertical-center'
is the <body> element */
/* Make it a flex container */
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
/* Align the bootstrap's container vertically */
-webkit-box-align : center;
-webkit-align-items : center;
-moz-box-align : center;
-ms-flex-align : center;
align-items : center;
/* In legacy web browsers such as Firefox 9
we need to specify the width of the flex container */
width: 100%;
/* Also 'margin: 0 auto' doesn't have any effect on flex items in such web browsers
hence the bootstrap's container won't be aligned to the center anymore.
Therefore, we should use the following declarations to get it centered again */
...