I'm using an often-referred to class to center my content both horizontally and vertically inside a flex container. It works across all modern browsers, but even fairly new Internet Explorer versions are giving me trouble.
Here's the relevant portion of my markup, making (ab)use of Bootstrap's embed-responsive classes to maintain ratio.
HTML:
<div class="container-fluid embed-responsive embed-responsive-16by9" style="background: linear-gradient(to bottom, rgba(0,0,0,0) 0%,rgba(0,0,0,0.5) 100%), url('http://placehold.it/800X600') no-repeat;background-size:cover;background-position:center">
<div class="content-center">
<div class="container">
<div class="row">
<div class="col-xs-12 text-center">
<button id="play-video" type="button" class="btn btn-default" data-toggle="modal" data-target="#video-modal" data-youtube="scWpXEYZEGk">
Play
</button>
</div>
</div>
</div>
</div>
</div>
CSS:
.content-center {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
-ms-flex-pack: center;
align-items: center;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
float: none;
}
Unfortunately, the elements are not centered but at the right of the page.
Here's a screenshot for reference