Centering web page content : always in the center no matter what

Hi!<br />
<br />
Visit : <br />
<br />
<!-- m --><a class="postlink" href="http://www.thedigiport.com">http://www.thedigiport.com</a><!-- m --><br />
<!-- m --><a class="postlink" href="http://www.onlinedigimon.com/site.php?goto=main">http://www.onlinedigimon.com/site.php?goto=main</a><!-- m --><br />
<br />
Now, adjust your screen resolution to 1024 * 768.<br />
<br />
Notice that the web content of these 2 sites are in the middle of the web browser! How neat! :eek::eek::)<br />
<br />
Can someone please show me how to achieve this? I would really appreciate it! Thanks! :) :) :)<!--content--><center> table </center><!--content-->alot of people do still resort to the deprecated <center> tags, but there are other ways, nest all the content in a 100% div with text-align:center; in the style, to overcome some browser problems with inline & block level elements add another div inside the larger div but still holding the content (no need for this one to be 100%) and add margin;0px auto; to it's style, ie:<br />
<br />
<div style="width:100%;text-align:center;"><br />
<div style="margin:0px auto;"><br />
<br />
content<br />
<br />
</div><br />
</div><br />
<br />
:)<!--content-->Thank you, Leo and Modulus! :):)<br />
<br />
Hi Leo! Below is my code :<br />
<br />
<HTML><br />
<HEAD><br />
<TITLE>1</TITLE><br />
<META NAME="description" CONTENT="1"><br />
<META NAME="keywords" CONTENT="1"><br />
<META NAME="Generator" CONTENT="Cool Page version 2.7 Webmaster, Aug 11 2001 for Windows"><br />
<BASE TARGET="_top"><br />
<STYLE TYPE="text/css">BODY {margin-left:0; margin-right:0; margin-top:0;}</STYLE><br />
<STYLE TYPE="text/css"><br />
.Arial-16pxn {font:normal 16px Arial, sans-serif}<br />
</STYLE><br />
</HEAD><br />
<br />
<BODY SCROLL="auto" BGCOLOR="#FFFFFF" TOPMARGIN=0 LEFTMARGIN=0><br />
<br />
<div style="width:100%;text-align:center;"><br />
<div style="margin:0px auto;"><br />
<br />
<DIV ID="idElement1" style="position:absolute; top:60px; left:3px; width:225px; height:300px;"><IMG <br />
<br />
SRC=http://www.htmlforums.com/archive/index.php/"Beelzemon_Blast_Mode.jpg" NAME="idElement1Img" ID="idElement1Img" WIDTH=225 HEIGHT=300 BORDER=0></DIV><br />
<br />
<DIV ID="idElement4" style="position:absolute; top:364px; left:9px; width:199px; height:30px;"><TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=199><TR VALIGN=top><TD><DIV align=left><FONT <br />
<br />
CLASS=Arial-16pxn>Hi!!!!!!</FONT></DIV></TD></TR></TABLE></DIV><br />
<br />
</div><br />
</div><br />
<br />
</BODY><br />
</HTML><br />
<br />
As you can see, there's a picture and a line of text on my web page.<br />
In the code highlighted above, the Red lines are the code you gave me and the Bolded lines are the content of my page.<br />
But still, it doesn't center!(appears at some weird positions instead)<br />
<br />
Hope you can help me again, Leo.<br />
Thanks! :)<br />
Xeon.<!--content--><DIV ID="idElement1" style="position:absolute; top:60px; left:3px; width:225px; height:300px;"><br />
<br />
is where your problem lies<br />
<br />
its overriding the other positioning command.<!--content-->gregory is quite correct!<br />
position:absolute; breaks all other positioning, you'll have to change it a bit for the centering to work :)<!--content-->Thanks guys! :):)<br />
<br />
But change the 'position:absolute' code for the centering to work? It seems that I've to compromise in the sense that if I wanna center the content on the web browser, I cannot place pictures at anywhere I like, right? :(:(<br />
<br />
Seems that I 've choose between one?<br />
<br />
Hmmm....maybe the <center>...</center> can do it? :)<!--content-->Originally posted by Xeon <br />
Thanks guys! :):)<br />
<br />
But change the 'position:absolute' code for the centering to work? It seems that I've to compromise in the sense that if I wanna center the content on the web browser, I cannot place pictures at anywhere I like, right? :(:(<br />
<br />
Seems that I 've choose between one?<br />
<br />
Hmmm....maybe the <center>...</center> can do it? :) <br />
<br />
well, give it a try, but i dont think it will work.<br />
<br />
my suggestion: stay away from absolute positioning, as it is very unpredictable on different browsers and resolutions.<!--content-->having a div with 100% width with text-align center will not center all content, it will center text but not any block elements, at least in any browser besides IE.<!--content-->Hi guys,<br />
<br />
<br />
<DIV ID="idElement1" style="position:absolute; top:60px; left:3px; width:225px; height:300px;"><IMG SRC=http://www.htmlforums.com/archive/index.php/"Beelzemon_Blast_Mode.jpg" NAME="idElement1Img" ID="idElement1Img" WIDTH=225 HEIGHT=300 BORDER=0></DIV><br />
<br />
I took away the bolded code above, and added the <center>...</center> tages, and it works!<br />
<br />
But that has taken away my ability to put pictures where I want them, even after I've changed the top:60px and left:3px attributes.<br />
<br />
But on some web sites, though, I saw that they can actually have the best of both world : the whole web site is centered in the web browser, and the pictures can appear at flexible positions.<br />
<br />
Some examples are <!-- m --><a class="postlink" href="http://www.yahoo.com">http://www.yahoo.com</a><!-- m --> and <!-- m --><a class="postlink" href="http://www.altavista.com">http://www.altavista.com</a><!-- m -->. />
<br />
I've also heard about putting everything in a table and then centering the whole darn thing horizontally in the browser.<br />
<br />
In addition, I've got this code through one of the older posts in HTMLForums. Here it is :<br />
<style type="text/css" media="screen"><br />
body {<br />
background-color:#fff;<br />
}<br />
#content {<br />
position:absolute;<br />
left:50%;<br />
width:760px;<br />
margin-left:-380px; <br />
background-color:#eee;<br />
text-align:left;<br />
}<br />
body>#content {<br />
margin-left:-380px; /* Correct value. */<br />
}<br />
</style><br />
</head><br />
<body><br />
<div id="content"> <br />
<br />
Could this be what suits me? :eek: <br />
<br />
I'm pretty desperate now, so as long as it works, I don't really care too much. :)<br />
<br />
Thanks!<br />
Xeon. :)<!--content-->ok, at this point in your learning i think you should take yourself over to w3schools and have a look at their css positioning (<!-- m --><a class="postlink" href="http://www.w3schools.com/css/css_positioning.asp">http://www.w3schools.com/css/css_positioning.asp</a><!-- m -->) , you already know a bit, position:absolute; is css, don't worry it will be easy to pick up :)<!--content-->Thanks Leo! But all the stuff there are pretty basic and fundamental, and they never mention anything about centering your page, but just stuff on "how to position text X-th pixels from the top of browser" etc. :(<br />
Help!<br />
<br />
Also, there's this "liquid layout" technique that allows the web pages to fill the browser, I think.<br />
(go to <!-- m --><a class="postlink" href="http://www.gamefaqs.com">http://www.gamefaqs.com</a><!-- m --> and view it at a very high resolution)<br />
<br />
Thanks,<br />
Xeon. :)<!--content-->I have a problem with this...<br />
<br />
On this (<!-- m --><a class="postlink" href="http://www.joshmccrain.com/autographhomepage2.htm">http://www.joshmccrain.com/autographhomepage2.htm</a><!-- m -->) page that menu on the left is placed by editing the pixel distance it is from the right and top of the screen. Well when you put a <center> around it and then change the size of teh actual page, the menu moves off of where it should be. Is there a way to get around this?<!--content-->
 
Back
Top