Created
October 9, 2012 07:12
-
-
Save anthonyringoet/3857126 to your computer and use it in GitHub Desktop.
Center with calc(), tip from Lea Verou presentation
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
/** | |
* Center with calc(), tip from Lea Verou presentation | |
*/ | |
body{ | |
/* housekeeping */ | |
background: #ffa; | |
min-height: 100%; | |
font-family:sans-serif; | |
} | |
section{ | |
background:#0f0; | |
width:60%; | |
margin:0 calc(50% - 30%); | |
} | |
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
<!-- tip from http://lea.verou.me/more-css-secrets --> | |
<section> | |
<p>Centered inside</p> | |
</section> |
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":"split","fontsize":"100","seethrough":"","prefixfree":"1","page":"all"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's Lea's slides: http://lea.verou.me/more-css-secrets/#padding-auto
This is what she really does:
section {
width: 700px;
padding: 0 calc(50% - 350px);
}