I am trying to centre a layout. I have been using a css hack which is not the best option to do.
My previous method(
http://www.rajsolutions.net/center2.html)
CSS code below
body {
background-color: #336633;
margin: 0px;
padding: 0px;
background-image: url(images/bg_center_green.gif);
background-repeat: repeat-y;
background-position: center;
}
#container {
position:absolute;
left:50%;
top:0px;
width:980px;
height:786px;
margin-left: -490px;
background-color: #73B131;
}
#logo_ {
position:absolute;
left:42px;
top:0px;
width:418px;
height:71px;
}
#topmenu_ {
position:absolute;
left:671px;
top:22px;
width:267px;
height:34px;
margin: 0px;
}
This makes the container stay in the middle I nest all the divs inside the Container div.(topmenu_ and logo_ are id of div)
I realised that is not a right way to centre a tableless layout. Especially since I now I am designing site for 1024 screen size. Earlier I used to design for 800 screen size and there was no problem(as 640X480 monitors do not exist and if I think can be conviniently ignored) But now with a 1024 layout if opened in a n 800X600 screen size the entire layout gets a negatively positioned out of the screen to the left.
So I took some help and found the following way to center my divs. This again uses the containter div but positions it the followint way(
http://www.rajsolutions.net/center.html)
CSS code below
body {
text-align: center;
background-color: #336633;
background-image: url(images/bg_center_green.gif);
background-repeat: repeat-y;
}
#container {
margin: 0 auto;
width: 980px;
background-color: #73B131;
text-align: left;
}
As you can see the containter has a background-color: #73B131; Which is not being "rendered".
Morover if you notice The background is perfectly aligned in (
http://www.rajsolutions.net/center2.html) It is there to create some sort of a shadow effect.
But when i am using the new method(which i believe is a better way to position it) the BG does not match and it does not stay in one postions in different screen resolutions. At a smaller resolution i.e. 800 it just goes haywire(the previouse method i.e. (
http://www.rajsolutions.net/center2.html) at smaller resolution layout goes into negative positioning on the left so you cannot really see the background.(which is worse)
Could you tell me the right way to achieve this ((
http://www.rajsolutions.net/center2.html)) using css.
Thank you.