-
-
Save ljayz/3312867 to your computer and use it in GitHub Desktop.
Vertical centering CSS technique
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
/** | |
* Vertical centering CSS technique | |
*/ | |
div:before, | |
div p {display:inline-block; vertical-align:middle;} | |
div:before {content:" "; height:100%;} | |
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
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<title>Vertical centering CSS technique</title> | |
<link rel="stylesheet" href="index.css"> | |
<div style="height:100px; border:1px solid;"> | |
<p style="border:1px dotted;">I'm vertically centered.</p> | |
</div> |
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:before, | |
div p {display:inline-block; vertical-align:middle;} | |
div:before {content:" "; height:100%;} | |
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
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<title>Vertical centering CSS technique</title> | |
<link rel="stylesheet" href="index.css"> | |
<div style="height:100px; border:1px solid;"> | |
<p style="border:1px dotted;">I'm vertically centered.</p> | |
</div> |
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
{"view":"separate","fontsize":"100","seethrough":"1","prefixfree":"1","page":"all"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment