Menu #forth-try
Elements are dynamically centered without the container being centered with a fixed with. Inline blocks are used to achieve this. Support: IE7+ and modern browsers.
by sapioit
HTML
<ul>
<li><a href="#">Home</a></li><li><a href="#">Careers</a></li><li><a href="#">About</a></li><li><a href="#">Contact</a></li>
</ul>
CSS
ul { position: absolute; width: 100%; top: 50%; margin-top: -10px; text-align: center; }
li { display: inline-block; list-style: none; padding: 5px 0; margin-left: 5px; }
li:first-child { margin-left: 0; }
li {
background: #82B5DA;
border: 1px solid #599CCE;
border-radius: 3px;
box-shadow: 0 0 3px rgba(0,0,0,0.3);
line-height: 20px;
padding: 0 5px;
}
li:hover { background: #599CCE; }
li a { color: #333; text-decoration: none; text-shadow: 1px 1px 0 rgba(255,255,255,0.3); }
/* IE7 Hack - http://www.brunildo.org/test/InlineBlockLayout.html */
li { *display: inline; zoom: 1; }
?
JavaScript
/*
Browser support: IE7+ and modern browsers.
*/