Created
November 13, 2013 23:52
-
-
Save emilstahl/7458694 to your computer and use it in GitHub Desktop.
Center an image vertically and horizontally in a container URL: http://www.brunildo.org/test/img_center.html Thanks to Brunildo.org for this: http://www.brunildo.org/test/img_center.htmll
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
<style type="text/css"> | |
.wraptocenter { | |
display: table-cell; | |
text-align: center; | |
vertical-align: middle; | |
width: ...; | |
height: ...; | |
} | |
.wraptocenter * { | |
vertical-align: middle; | |
} | |
/*\*//*/ | |
.wraptocenter { | |
display: block; | |
} | |
.wraptocenter span { | |
display: inline-block; | |
height: 100%; | |
width: 1px; | |
} | |
/**/ | |
</style> | |
<!--[if lt IE 8]><style> | |
.wraptocenter span { | |
display: inline-block; | |
height: 100%; | |
} | |
</style><![endif]--> |
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
<div class="wraptocenter"><span></span><img src="..." alt="..."></div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment