html - Vertically center fixed size div inside an other div -


i have created small 'template', containing title, image , 2 links.

i want center template (class: plant-row) vertically in page, can't it.

i have tried use display:table on plant-inner-col, , display:table-cell on template, breaks image size limitation, ends taking entire screen.

could please me find way vertically center box, without giving on setting size?

note: whole thing uses bootstrap, hence classes, don't thing has impact here, therefore, elected keep fiddle simple.

cheers,

.kpi-homepage-container{      margin-left:0px;      margin-right:0px;      padding-left:0px;      padding-right:0px;      top:0;      left:0;      right:0;      bottom:0;      position:fixed;      background-color: #f5f5f5;      width:100%;  }  .plant-col {    height: 100%;    padding-top: 5px;    padding-bottom: 5px;    text-align: center;  }    .plant-inner-col {    height: 100%;    padding-left: 7.5px;    padding-right: 7.5px;    float: none;    margin: 0 auto;  }    .plant-row {    box-sizing: border-box;    box-shadow: 1px 1px 1px;    height: calc((100% - 35px)/2);    text-align: center;    border: 1.5px solid;    border-radius: 2px;    overflow: hidden;  }    .plant-row .plant-name {    font-size: 18px;    padding-top: 5px;  }    .plant-row .plant-img {    height: 70%;  }    .plant-row .plant-link {    height: 15%;    margin-top: 10px;  }
<div class="kpi-homepage-container">    <div class="col-md-12 plant-col">      <div id="template-container" style="max-width:700px; height:100%; margin: 0 auto;">        <div class="col-md-6 plant-inner-col">          <div class="plant-row">            <p class="plant-name">hmd</p><img class="plant-img" src="https://s-media-cache-ak0.pinimg.com/originals/a8/39/35/a83935a027475e34ebace7d4a1ed33e8.jpg">            <div class="row plant-link">              <div class="col-md-6"><a class="btn btn-primary" href="#">to level 0</a></div>              <div class="col-md-6"><a class="btn btn-info" href="#">to level 1</a></div>            </div>          </div>        </div>      </div>    </div>  </div>

is need? turned .plant-inner-col flexbox vertical alignment in center.

.kpi-homepage-container{      margin-left:0px;      margin-right:0px;      padding-left:0px;      padding-right:0px;      top:0;      left:0;      right:0;      bottom:0;      position:fixed;      background-color: #f5f5f5;      width:100%;  }  .plant-col {    height: 100%;    padding-top: 5px;    padding-bottom: 5px;    text-align: center;  }    .plant-inner-col {    height: 100%;    padding-left: 7.5px;    padding-right: 7.5px;    float: none;    margin: 0 auto;    display: flex;    align-items: center;  }    .plant-row {    box-sizing: border-box;    box-shadow: 1px 1px 1px;    height: calc((100% - 35px)/2);    text-align: center;    border: 1.5px solid;    border-radius: 2px;    width: 100%;  }    .plant-row .plant-name {    font-size: 18px;    padding-top: 5px;  }    .plant-row .plant-img {    height: 70%;  }    .plant-row .plant-link {    height: 15%;    margin-top: 10px;  }
<div class="kpi-homepage-container">    <div class="col-md-12 plant-col">      <div id="template-container" style="max-width:700px; height:100%; margin: 0 auto;">        <div class="col-md-6 plant-inner-col">          <div class="plant-row">            <p class="plant-name">hmd</p><img class="plant-img" src="https://s-media-cache-ak0.pinimg.com/originals/a8/39/35/a83935a027475e34ebace7d4a1ed33e8.jpg">            <div class="row plant-link">              <div class="col-md-6"><a class="btn btn-primary" href="#">to level 0</a></div>              <div class="col-md-6"><a class="btn btn-info" href="#">to level 1</a></div>            </div>          </div>        </div>      </div>    </div>  </div>


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

.htaccess - ERR_TOO_MANY_REDIRECTS htaccess -