The way I usually do it is using absolute position:
#inner{
left: 0;
right: 0;
margin-left: auto;
margin-right: auto;
position: absolute;
}
#inner {
left: 0;
right: 0;
margin-left: auto;
margin-right: auto;
position: absolute;
}
<div id="outer">
<div id="inner">Foo foo</div>
</div>
The outer div doesn't need any extra properties for this to work.