Created
April 6, 2012 16:34
-
-
Save mateuszkocz/2321182 to your computer and use it in GitHub Desktop.
Centring some element
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
.wrap { | |
/* Unimportant styling. */ | |
background-color: #ffa500; | |
width: 400px; | |
height: 200px; | |
/* Solution (part I)*/ | |
/* This code allows element inside the .wrap to be positioned in the middle. */ | |
display: table-cell; | |
vertical-align: middle; | |
} | |
.centre { | |
/* Another unimportant styling. */ | |
width: 200px; | |
background-color: #424242; | |
color: #fff; | |
text-align: center; | |
/* Solution (part II) */ | |
/* Now we have a vertical centring. */ | |
margin: 0 auto; | |
} |
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
<div class="wrap"> | |
<div class="centre">I'm the centre of the universe!</div> | |
</div> |
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","seethrough":"","prefixfree":"1","page":"css"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment