Created
February 12, 2012 14:56
-
-
Save madr/1808914 to your computer and use it in GitHub Desktop.
Valign=middle without tables, IE6+ compatible
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
/* @group valignfix */ | |
/* *************************************** | |
valignfix, by Anders Ytterström @ madr.se | |
**************************************** */ | |
/* | |
HTML fixture: | |
.valign | |
%div | |
%div | |
%h1 | |
%h2 | |
%img | |
*/ | |
/* @group ie8, ff, opera, safari | |
===================================== */ | |
body > div { | |
display:table; | |
} | |
*.valign { | |
display:table-row; | |
} | |
*.valign > * { | |
width:50%; | |
display:table-cell; | |
vertical-align:middle; | |
} | |
/* @end ie8, ff, opera, safari | |
===================================== */ | |
/* @group ie6,ie7 | |
===================================== */ | |
/* | |
use this in CC file. | |
Works only in standards mode. | |
*/ | |
* html *.valign, | |
*+html *.valign { | |
position:relative; | |
overflow:auto; | |
} | |
* html *.valign div, | |
*+html *.valign div { | |
position:absolute; | |
top:50%; | |
} | |
* html *.valign div div, | |
*+html *.valign div div { | |
position:relative; | |
top:-50%; | |
} | |
* html *.valign div div *, | |
*+html *.valign div div * { | |
position:static; | |
top:0; | |
} | |
* html *.valign img, | |
*+html *.valign img { | |
float:right; | |
} | |
/* @end ie6, ie7 | |
===================================== */ | |
/* **************************************** | |
/valignfix, by Anders Ytterström @ madr.se | |
**************************************** */ | |
/* @end valignfix */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment