stacking layers

Hello -<br />
<br />
I know I can use Z-index to stack abosolutely positioned layers, is it possible to create layers that are relatively placed and stack them on top of one another?<br />
<br />
I'm using CSS<br />
<br />
Cole<!--content-->should be possible, have you tried it?<!--content-->It's possible, Cole, but not all browsers render the z-axis the same. You could run into some major headaches with it.<br />
<br />
Peg<!--content-->OK - I posted yesterday and all I got was, it's possible... obviously it's not that simple or I wouldn't be needing help... so let's try thig again...<br />
<br />
I have two layers <div id=x1>...</div> and <div id=x2>some text</div><br />
<br />
Here is my CSS <br />
#x1 #x2{<br />
clear: both;<br />
text-indent: 6px;<br />
color: #FFFFFF;<br />
font-size: 16px;<br />
font-style: italic;<br />
font-weight: bold;<br />
position: relative;<br />
visibility: hidden;<br />
z-index: 100;<br />
}<br />
<br />
What i want to acheive is the effect that these layers are absolutely positioned on top of one another - I can't actually do that because of the site is assembled<!--content-->didn't need to start another thread!<br />
<br />
1 min i'll have alook, the phone's ringing :D<!--content-->lets see<br />
<br />
div.a {position:absolute;top:10px;left:10px;z-index:1;}<br />
<br />
div.b {position:absolute;top:10px;left:10px;z-index:2;}<br />
<br />
that would 'stack' div 'b' directly above div 'a', is that what you want?<!--content-->Originally posted by colenielsen <br />
OK - I posted yesterday and all I got was, it's possible... obviously it's not that simple or I wouldn't be needing help... so let's try thig again...<br />
<br />
I have two layers <div id=x1>...</div> and <div id=x2>some text</div><br />
<br />
Here is my CSS <br />
#x1 #x2{<br />
clear: both;<br />
text-indent: 6px;<br />
color: #FFFFFF;<br />
font-size: 16px;<br />
font-style: italic;<br />
font-weight: bold;<br />
position: relative;<br />
visibility: hidden;<br />
z-index: 100;<br />
}<br />
<br />
What i want to acheive is the effect that these layers are absolutely positioned on top of one another - I can't actually do that because of the site is assembled <br />
you can't stack them because they are both the same z-index. you are using the same style for both. and yes it is possible and I believe Kevin was assuming you already knew the code since you asked about using z-index.<!--content-->Ok even changing the Z-index doesn't work - I only noted it that way for simplicity sake - they actual Z-indexes are 100 and 101 respectively.<br />
<br />
<br />
div.a {position:absolute;top:10px;left:10px;z-index:1;}<br />
<br />
div.b {position:absolute;top:10px;left:10px;z-index:2;}<br />
<br />
<br />
Yes, this is what I want EXCEPT "position:absolute;top:10px;left10pxx;" I can't position the layers absolutely because of the rest of the document and problems with browser exactness of rendering when crossing relative and absolute positioning schemes.<!--content-->ok, just change it to relative then,<br />
<br />
position:relative;top:10px;left:10px;<br />
<br />
<br />
no matter what positioning style you use you can still stack different layers :D<!--content-->you can't say that. first you ask if it is possible and then you show us the code you use and say it doesn't work.. well then you say that isn't even the code you use.<br />
<br />
we can't help you if you are not being honest or anything.<br />
<br />
if you use z-index then what difference does it make if you absolute position it or not, it will be sticking above all other elements anyway. and you can't talk about not rendering correctly in all browsers because that is what you get with css, not all of them will do it correctly anyway.<br />
<br />
and besides you told it to not show.<br />
<br />
you are not making any sense. if you can't position them how do you expect them to be on top of each other. you ahve to use left and top to do what you want.<!--content-->you can do it but since the positioning is relative you have to give relative coordinates:<br />
<br />
<br />
<div style="width:100px;height:100px;z-index:2;border:1px red solid;"><br />
words words words<br />
</div><br />
<div style="position:relative;top:-100;left:0;width:100px;height:100px;z-index:3;border:1px blue solid;"><br />
this div will stack over the first div<br />
</div><!--content-->or you could do it the other way around kevin, have the second div in the normal flow and position the first over it, that way you'd avoid negative values.<br />
<br />
But at the end of the day, if he'd followed your advice to try it at the start this thread would have only been two posts long:P<!--content-->yeah :) and as a side note kevin, that wouldn't work anyway. you can't use negative numbers as mozilla doesn't like them<!--content-->ONCE AGAIN - you are all wrong - first of all you're flaming for no reason... I understand that it COULD work - and SHOULD work in most cases... the problem is that I need to insure cross-browser compatability... using relative placements has never worked properly for me before - it still positions things absolutely in most cases.... for example...<br />
<br />
<div style="position:relative;top:10px;left:10px"><br />
<div style="position:relative;top:10px;left:10px"><br />
some stuff<br />
</div><br />
</div><br />
<br />
This should technically place the top,left corner of the second DIV at 20,20 - it still places it at 10,10 at least in the latest build of Mozilla and every one I've used prior. I see the same results in Safari and Opera(sometimes).<br />
<br />
Don't give me that it works in Explorer crap... because it's exaclty that... It's all good but I develop on an open-source platform and intend to keep campatability to a maximum.<!--content-->dude, nobody has flamed you. you can't even tell us what you want as we have ALL given perfect examples of what you works and you shoot us down.<br />
<br />
for one your code:<br />
<br />
<div style="position:relative;top:10px;left:10px"><br />
<div style="position:relative;top:10px;left:10px"><br />
some stuff<br />
</div><br />
</div><br />
<br />
edit:<br />
will go to 20,20 of the page but 10,10 of the outer div.<br />
<br />
<br />
by default ALL block level elements are postioned relative (theoretically) but in order for you to load a div on top of another div you have to absolute position it.<br />
<br />
<div style="width:100px;height:100px;z-index:2;border:1px red solid; top:0;left:0;"><br />
words words words<br />
</div><br />
<div style="position: absolute; top:0;left:0;width:100px;height:100px;z-index:3;border:1px blue solid;"><br />
this div will stack over the first div<br />
</div><br />
<br />
that code works for me in IE, and that is good considering IE doesn't do 90% of css2.<br />
<br />
so if this doesn't work for you then I will gracefully bow out of this conversation as it seems you know a lot more html and css than I.<!--content-->So the simple answer to my question is that for this to work I must absolutely position my layers otherwise they will not stack on top of one another.<br />
<br />
To acheive the goal that I was wanting I did find an alternative method using javascript - Instead of stacking layers, just change the contents of the DIV ;)<br />
<br />
Thanks for the help<!--content-->Originally posted by colenielsen <br />
Don't give me that it works in Explorer crap... because it's exaclty that... It's all good but I develop on an open-source platform and intend to keep campatability to a maximum. <br />
<br />
Then you should maybe be using a browser sniffer and a different style sheet depending on the browser. You seem to know that IE and most other browsers calculate the x-y coordinates a bit differently and sometimes very differently, so the only way for true cross-browser compatabilty is a custom style sheet for each browser/browser version. Plus then you have to take into account the platform and the viewing device, ugh!<!--content-->
 
Back
Top