I am creating a site in bootstrap, and I want to know how to vertically center two child divs inside of a parent div. I know this is probably pretty simple, but I have tried everything and it will not work.
(http://codepen.io/cjhill02/pen/VLPERd)
I am creating a site in bootstrap, and I want to know how to vertically center two child divs inside of a parent div. I know this is probably pretty simple, but I have tried everything and it will not work.
(http://codepen.io/cjhill02/pen/VLPERd)
try margin:auto
* {
border: 1px solid #ddd;
}
section {
padding: 100px 0;
margin: auto
}
.col-md-6{
margin: auto
}
for IE9 and IE10 put display:table to parent div and set attribute vallign="middle";display:table-cell to child element
vallign is a basic property supperted by old browsers as well as some new browsers
You can always do it with display: flex;
.container {
display:flex;
width:100%;
align-items: center;
justify-content: center;
height: 400px;
border: 4px solid black;
}
.container div {
display:flex;
align-items: center;
justify-content: center;
}
.container > div {
width: 40%;
background-color: red;
height: 221.5433px;
}
.container > div + div {
width: 40%;
background-color: brown;
height: 278.8431px;
}
<div class="container">
<div>centered</div>
<div>centered</div>
</div>