Created
March 1, 2012 15:46
-
-
Save stuartgamblen/1950621 to your computer and use it in GitHub Desktop.
CSS: Center inner div with no outer width
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
/* Center inner div with no outer width */ | |
div.wrapper{ | |
float: left; | |
overflow: hidden; | |
position: relative; | |
width: 100%; | |
background: #F5F5F5; | |
padding: 10px; | |
margin: 0 -20px; | |
} | |
div.outer{ | |
clear: left; | |
float: left; | |
left: 50%; | |
list-style: none outside none; | |
margin: 0; | |
padding: 0; | |
position: relative; | |
text-align: center; | |
} | |
div.inner{ | |
display: block; | |
float: left; | |
margin: 0; | |
padding: 0; | |
position: relative; | |
right: 50%; | |
color: #FFF; | |
padding: 5px 20px; | |
background: #8CC942; | |
} |
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="wrapper"> | |
<div class="outer"> | |
<div class="inner">Centering the DIV</div> | |
</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":"all"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment