Need help: Almost dead struggling
Posted: 29 April 2006 06:04 AM   [ Ignore ]
Newbie
Rank
Total Posts:  3
Joined  2006-04-29

Hi all,
I need some help here. I have tried and treied… but I do not seem to be getting this right.

I need to create 3 layers;
=> all horizontally center aligned for any screen resolution & any browser,
=> all of same size & exactly overlapping each other


I have tried so many different combination, but none seem to work.

I have posted on many forums too, but no help.

Looking for some assistance.

regards,
Vai

Profile
 
 
Posted: 30 April 2006 12:52 AM   [ Ignore ]   [ # 1 ]
Newbie
Rank
Total Posts:  1
Joined  2006-04-30

I saw your post but it was a little unclear to me what you were trying to accomplish.  I have no doubt that I can help you, but please be a little more descriptive.

Profile
 
 
Posted: 30 April 2006 06:21 PM   [ Ignore ]   [ # 2 ]
Newbie
Rank
Total Posts:  3
Joined  2006-04-29

Thx Eddy. I will try to explain.
I am trying to create 3 layers.
<div id=“layer1”>
something here
</div>
<div id=“layer2”>
something here
</div>
<div id=“layer3”>
something here
</div>

I need all these 3 layers to be of the same dimensions & to be overlapping each other.
In effect this means that only “layer3” will be visible.

Another factor is that if I resize my browser or view with any screen resolution, the layers should still be center aligned and exactly overlapping with “layer1” & “layer2” not visible to the users.
I do not wish to user the “hidden” property.

I hope this is clear :)

I look forward to your suggestions.
Thx again / Vai

Profile
 
 
Posted: 01 May 2006 08:28 AM   [ Ignore ]   [ # 3 ]
Newbie
Rank
Total Posts:  17
Joined  2006-03-09

i packed them all in container. not necessary, but easier, and clearer.
relation established with position relative on parent, and position absolute (in relation to parent, lol) for inner, child elements.

margin auto on parent takes care of horizontal centering that div, with all inner content.  same positioning will overlap inner divs over each oder. bg colors and borders are there just to make things more obvious.
here goes:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<
html>

<
head>
  <
title></title>
  <
style  type="text/css">

#container {position:relative;margin:100px auto; height:300px;width:300px; border:1px solid red;}

#layer1, #layer2, #layer3{position:absolute; left:0;top:0; height:300px;width:300px; background-color:yellow;}

</style>
</
head>
<
body>

<
div id="container">

    <
div id="layer1">
    
something here
     
</div>
     <
div id="layer2">
     
something here
    
</div>
    <
div id="layer3">
    
something here
     
</div>

</
div>


</
body>
</
html

p.s.:but may i ask, what is the purpose of it? what exactly are you trying to accomplish, coz maybe it can be done more effectively using something completely different
p.p.s.:please avoid use of term “layer”..it associate to graphics, not css/html -only DW use that and it can be pretty confusing :p
there’s nothing wrong with divisions

Profile
 
 
Posted: 01 May 2006 11:02 AM   [ Ignore ]   [ # 4 ]
Newbie
Rank
Total Posts:  3
Joined  2006-04-29

Hey, Thx a lot. This seemed so simple.
I have made some small changes in the CSS and I think I will need your help again.

Modified CSS is as beow. I have resized the container to cover the browser windows at 800x600 resolution.
I believe at any other resolution it will be ositioned at the center with equal margins left on either sides.
But now the layers are left aligned. HOw do I center align them.
I cannot give specific values to top & left cuase they will change for different screen resolution.
I tried some other combinations, but none worked.
Pls advice.

As regards what I am trying to do….. :) hidden text for SEO…. ;)

cheers,
Vai

—————————————
#container {position:relative;margin:0px auto; height:600px;width:800px; border:1px solid red;}

#layer1{position:absolute; left:0;top:0; height:300px;width:300px; background-color:yellow;}
#layer2{position:absolute; left:0;top:0; height:250px;width:300px; background-color:red;}
#layer3{position:absolute; left:0;top:0; height:200px;width:300px; background-color:blue;}

—————————————

Profile
 
 
Posted: 01 May 2006 04:44 PM   [ Ignore ]   [ # 5 ]
Newbie
Rank
Total Posts:  17
Joined  2006-03-09

hehehee
i was guessing somtin like that :p.. still, be carefull, it can backfire sooner or later.. have you thought about how that thing would look in text-only browsers? or on screen-readers? anything that does not suport css, or with css turned of ??

so…margin:auto; takes care of centering block level elements, add it to style of your inner blocks as well.

and for centering text or images inside, add text-align:center; to containers CSS

Profile
 
 
Posted: 01 May 2006 05:07 PM   [ Ignore ]   [ # 6 ]
Newbie
Rank
Total Posts:  17
Joined  2006-03-09

oops, sorry, my bad..margin auto isnt working for inner stuff, but..if you know all widths i see no problem in seting fixed margins, something like
#layer1{position:absolute;height:300px;width:300px; background-color:yellow;margin-top:150px;margin-left:250px;}

..also, your fear of setting starting position of inner div is not justified, becaouse it sets that position in relation to parent element, #container, and not body. if #container has set width, no problem there.

Profile