I can't seem to make text stay centred in a container if it overflows that container. In my example, it's a horizontal menu within a fluid layout. It works fine until the browser window is shrunk sufficiently for the text to overflow. Once this happens, it no longer stays centred, but rather overlaps only to the right.
How can I make it stay centred, even when it has to overflow its container?
Here's my code:
<style type="text/css">
#access {
background: #e2e2e2;
width: 100%;
margin-left:auto;
margin-right:auto;
}
#access div {
width: 100%
margin-left:auto;
margin-right:auto;
}
#access ul {
font-size: 0.9em;
list-style: none outside none;
display: inline-block;
width: 100%;
text-align: center;
}
#access li {
width: 15%;
position: relative;
margin-right: 1%;
float: left;
}
#access a {
color: #fff;
width: 62%;
margin-left:auto;
margin-right:auto;
background: #CB2027;
display: inline-block;
line-height: 2.2em;
margin-left: auto;
margin-right: auto;
text-align: center;
font-size: 1.2em;
padding: 0px 1em;
white-space: nowrap;
}
</style>
<nav id="access" role="navigation">
<div class="menu-test-menu-container"><ul id="menu-test-menu" class="menu">
<li id="menu-item-29"><a href="http://google.com/">Home</a></li>
<li id="menu-item-30"><a href="http://google.com/">Item 1</a></li>
<li id="menu-item-31"><a href="http://google.com/">Long item</a></li>
<li id="menu-item-32"><a href="http://google.com/">Item 3</a></li>
</ul></div></nav>
And here it is live: http://jsfiddle.net/Psymz/