Liquid positioning for different screen resolutions
Posted: 23 May 2008 12:09 AM   [ Ignore ]
Newbie
Rank
Total Posts:  9
Joined  2008-05-23

Hi everyone, I am trying to position an image in the center of my page using “left: 25%” but I noticed that when I change the resolution on my computer, the image gets pushed to the right quite a bit. Any suggestions? I am trying to center the “#main” div and this is my css:

body {
background
-color#000000;
margin0;
}
#header {
positionabsolute;
top0px;
left0px;
background-imageurl(images/headerbar.png);
width100%;
height54px;
}
#menu {
positionrelative;
top0px;
left25%;
background-imageurl(images/menubar.png);
width209px;
height274px;
padding-left25px;
margin-left450px;
background-repeatno-repeat;
}
#main {
positionrelative;
top0px;
left25%;
background-imageurl(images/mainimage.png);
width711px;
height270px;
background-repeatno-repeat;
color#ffffff;
}
#footer {
positionrelative;
top0px;
left0px;
background-imageurl(images/footerbar.gif);
width100%;
height154px;
Profile
 
 
Posted: 25 May 2008 02:24 PM   [ Ignore ]   [ # 1 ]
Member
Avatar
RankRankRank
Total Posts:  52
Joined  2007-11-08

To center your div#main, you shouldn’t be using positioning, but margins…Assign it the fixed width you wish..and put a margin:0 auto; and it will be centered in your viewport..Also, put a text-align:center; to body and text-align:left; to div#main..The text-align:center; will center div#main in your viewport fot IE6.0, and text-align:left; will align your text normally..

Profile