Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

7on

macrumors 601
Original poster
Nov 9, 2003
4,939
0
Dress Rosa
Is it possible to have absolute positioning (z-indexed above one another) but have the whole thing be in the center of the page?

An example being here. Let's say I wanted to make the whole thing in the middle float in the middle of the page without losing the placement of the various elements?
 
Create a container div and center that and set it to relative. Within, nest your object divs set as absolute and they will use the parent co-ords as a root point.
 
Could I have an example? Thanks!

I believe this is what Trip.Tucker was getting at.

HTML:
<div id="absolute-container">
  <div id="stuff"></div>
</div>

CSS:
Code:
#absolute-container {
 position: relative;
 margin: 0 auto; /* this will center the div */
}
#stuff {
 position: absolute;
 top: /* whatever */
}

Something I've messed with, but haven't tested too much is to something like (using only the stuff div from above),
Code:
#stuff {
 position: absolute;
 left: 25%; right: 25%;
}

I know there's certain times this won't work at all, but other times it will work perfectly even in IE.
 
I think I got it:

Code:
body {text-align: center;background-color: #E7E8EB;}
#container {margin-left: auto;margin-right: auto;width: 570px;text-align: left;position: relative;}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.