<style>
#frame
{
position:absolute;
left:50%;
width:780px;
margin-left:-390px;
}
</style>
<div id="frame">
[page content]
</div>
#frame
{
position:absolute;
left:50%;
width:780px;
margin-left:-390px;
}
</style>
<div id="frame">
[page content]
</div>
position:absolute; pulls the div up out of relative positioning, allowing you to place it anywhere. The 'left:50%' puts the left edge of the div in the center of the page. We then set the width of the div, in this case 780px. Then, to center the div's center to the page's center, we pull back the left margin by half the width of the div; in this case -390px. If the width were set to 700px, the margin-left would then be -350px.
That's it. Easy, pretty, and works cross-browser/resolution.
No comments:
Post a Comment