html - CSS - Center position is not working in IE having absolute position -


i have placed 3 div. first parent having css position relative , taking full width of viewport. 2nd children having absolute position cover area of parent. 3rd children having absolute position margin: 0 auto.

.slide-block {    position: relative;  }    .slide-block .slide-block-center-wrapper {    top: 0;    position: absolute;    left: 0;    right: 0;    bottom: 0;  }    .slide-block .slide-block-content {    max-width: 1180px;    margin: 0 auto;    padding: 0 30px;    position: absolute;    top: 50%;    transform: translate(0, -50%);    -moz-transform: translate(0, -50%);    -webkit-transform: translate(0, -50%);    -ms-transform: translate(0, -50%);    left: 0;    right: 0;  }
<div class="slide-block">    <div class="slide-block-center-wrapper">      <div class="slide-block-content">        ...some slide caption content      </div>    </div>  </div>

the problem is, .slide-block-content not appearing in center in ie browser. appearing in center in chrome , mozilla.

you can try solve below. element vertically centered height needs known. changed 3rd child inline block , used transform horizontally center it. if need vertically center it, can remove left: 50% , change translate translatey.

.slide-block {    position: relative;    width: 100%;    height: 200px;    background: deepskyblue;  }    .slide-block .slide-block-center-wrapper {    position: absolute;    top: 0;    left: 0;    right: 0;    bottom: 0;  }    .slide-block .slide-block-content {    display: inline-block;    max-width: 1180px;    padding: 0 30px;    position: absolute;    top: 50%;    left: 50%;    transform: translate(-50%);    -moz-transform: translate(-50%);    -webkit-transform: translate(-50%);    -ms-transform: translate(-50%);  }
<div class="slide-block">    <div class="slide-block-center-wrapper">      <div class="slide-block-content">        ...some slide caption content      </div>    </div>  </div>


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -