Friday, February 3, 2017

Centering an image horizontally and vertically in HTML5

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Logo</title>
</head>
<style>
img {
   position: absolute;
   top: 50%;
   left: 50%;
   width: 800px;
   height: 800px;
   margin-top: -400px; /* Half the height */
   margin-left: -400px; /* Half the width */
}
</style>
<body>
    <img src="Logo.png" />
</body>
</html>

No comments: