Created
November 14, 2011 17:38
-
-
Save decioferreira/1364559 to your computer and use it in GitHub Desktop.
CSS center div with unknown width
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
.container { | |
clear: both; | |
float: left; | |
width: 100%; | |
overflow: hidden; | |
} | |
#menu { | |
padding: 0; | |
list-style-type: none; | |
/* centering menu */ | |
margin: 0 auto; | |
float: left; | |
position: relative; | |
left: 50%; | |
} | |
#menu li { | |
/* centering list elements */ | |
float: left; | |
position: relative; | |
right: 50%; | |
} |
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
<div class="container"> | |
<ul id="menu"> | |
<li><a href="#">Elements</a></li> | |
<li><a href="#">With different</a></li> | |
<li><a href="#">Sizes</a></li> | |
</ul> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment