-1

Hi how do i place this image vertical in the middle of the div? The height of the header is different when you are login or logout!

<div class="header">
  <nav class="header-content columns" data-topbar role="navigation"> 
    <div class="logo-area">
      <?php echo logo_header(); ?>
    </div>
    <section class="header-content-section">

    </section>
  </nav>
</div>

How to set up the css that the image will stay vertical centered? .header-content .logo-area {

} .header-content .logo-area img {

}

Thanks

Rhoda
  • 99
  • 9
  • Theres a great answer to that question here: https://stackoverflow.com/questions/388180/how-to-make-an-image-center-vertically-horizontally-inside-a-bigger-div – perfection Sep 08 '17 at 11:33

2 Answers2

0

You can achieve this by putting an auto margin on the left and right, but you need to display your image as block, so it occupies all the space in the container.

.header-content .logo-area img { 
  display: block; 
  margin: 0 auto;
}
0

You can do it with flexbox

.header-content .logo-area {
  display: flex;
  justify-content: center;
}
.header-content .logo-area img {
  width:250px;
  height:250px;
}

Example : https://jsfiddle.net/q59wv9ew/2/

Ovidiu Unguru
  • 756
  • 5
  • 14