The value of position: absolute is exactly what you want to indicate how far from the page margins your div should be placed. Since you do not know the width of the screen a priori, there is no way to center it.
I think you just want to remove the div from the page stream, keeping it in the center. In this case, it may be sufficient to add a div container, for example
<div id="external"> <div id="internal"> </div> </div>
and CSS
#external { position: absolute } #internal { margin: 0 auto }
I have not tested the above layout, but I think it should work.
Andrea
source share