0

My website has a header and it takes 20% of screen. I want an image (which is 90% of header height) right in the center of the header. I had no problems to center the image horizontally, but I can't center it vertically. Here's the code:

<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>Website</title>
    <link rel="stylesheet" href="stylingpercent.css" />
</head>

<body>

    <header>
        <div class="logoheader" >
            <img class="mainlogo" src="logo.png" alt="logo">
        </div>

    </header>



</body>

</html>

body {
    margin:0px;
}


.logoheader{
    height: 20vh;
    background:rgb(1,1,1);
    margin:0px;
    text-align: center;
}


.mainlogo { 
    max-height:90%;
}
user3415893
  • 59
  • 2
  • 3
  • 8

1 Answers1

0

Add this:

line-height: 20vh;

to .logoheader. DEMONstration.

Mohammad Areeb Siddiqui
  • 9,795
  • 14
  • 71
  • 113