Created
February 2, 2016 22:43
-
-
Save Ashwinning/f2bd95ea9c37a78d119d to your computer and use it in GitHub Desktop.
Use this code to vertically and horizontally center something on a web page.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>This page is under construction</title> | |
<style> | |
.outer { | |
display: table; | |
position: absolute; | |
height: 100%; | |
width: 100%; | |
} | |
.middle { | |
display: table-cell; | |
vertical-align: middle; | |
} | |
.inner { | |
margin-left: auto; | |
margin-right: auto; | |
width: 744px; /* Width should be the exact with of the div or image that you want to center */ | |
} | |
</style> | |
</head> | |
<body> | |
<div class="outer"> | |
<div class="middle"> | |
<div class="inner"> | |
<img src="http://ayaassociates.com/wp-content/uploads/2013/08/page_is_under_construction.jpg"> | |
</div> | |
</div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment