Created
October 23, 2018 13:58
-
-
Save lqez/dbd80864725e1daed25812a60b0e0d39 to your computer and use it in GitHub Desktop.
Why we need margin-left for center-aligned text
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
<html> | |
<head> | |
<style> | |
body { | |
margin: 0; | |
} | |
h1 { | |
letter-spacing: 1em; | |
margin: 0; | |
} | |
div { | |
max-width: 400px; | |
margin: 1em auto; | |
text-align: center; | |
padding: 2em; | |
} | |
div.wrong { | |
background: red; | |
} | |
div.correct { | |
background: lime; | |
} | |
div.correct h1 { | |
margin-left: 1em; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="wrong"> | |
<h1>CENTER</h1> | |
</div> | |
<div class="correct"> | |
<h1>CENTER</h1> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment