I'm trying to get div #primary
to sit in the middle of the page with position: relative
and margin: 0 auto
, and I also want to have an <aside>
element that sits directly to the right of #primary
and does not shift around on width resize.
With margin: 0 auto
, I notice in Chrome/Firefox Developer Tools that this effectively gives #primary
full margins on either side, preventing anything from entering that space.
I tried giving #primary
float: left
, but this seems to cancel out the margin: 0 auto
and makes #primary
flush against the left side of the page.
How can I achieve this effect? Thanks.
#content {
margin: 0 auto;
width: 100%;
}
#primary {
position: relative;
width: 900px;
margin: 0 auto;
}
aside {
width: 350px;
float: right;
}
<div id="content">
<div id="primary"></div>
<aside></aside>
</div>