Last active
September 3, 2022 09:58
-
-
Save csssecrets/8aa9aa04ee57f479c513 to your computer and use it in GitHub Desktop.
Vertical centering - Flexbox solution
This file contains hidden or 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 - Flexbox solution | |
*/ | |
* { margin: 0 } | |
body { | |
display: flex; | |
min-height: 100vh; | |
} | |
main { | |
padding: 1em 2em; | |
margin: auto; | |
box-sizing: border-box; | |
background: #655; | |
color: white; | |
text-align: center; | |
} | |
h1 { | |
margin-bottom: .2em; | |
font-size: 150%; | |
} | |
body { | |
background: #fb3; | |
font: 100%/1.5 sans-serif; | |
} |
This file contains hidden or 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
<main> | |
<h1>Am I centered yet?</h1> | |
<p>Center me, please!</p> | |
</main> |
This file contains hidden or 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
// alert('Hello world!'); |
This file contains hidden or 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":"split-vertical","fontsize":"100","seethrough":"","prefixfree":"1","page":"css"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment