Previous Message
Next Message

need help with center a site??

Sent by Gunlaug_Sørtun on 30 April 2006 20:08


robert rai wrote:
> http://www.freewebs.com/jhinkoerai

> how can i edit the css file to make the website display in the center of the 
> browsers?

Start out by using a complete doctype that will trigger 'standard 
compliant mode' in browsers.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

....is a suitable one.

You can use these pages for DTD-references:
<http://www.w3.org/QA/2002/04/valid-dtd-list.html>
<http://gutfeldt.ch/matthias/articles/doctypeswitch/table.html>


Next: add some CSS...

body {
margin: 0;
padding: 0;
text-align: center /* center in old browsers */;
}

....which will zero out the default margins and paddings on body, and 
make older IE/win versions center the page too.

div.sitecontainer {
margin: 0 auto /* center the element */;
position: relative /* make it base for absolute positioning */;
text-align: left /* fix text-alignment */;
}

....which will center that container in standard compliant browsers,
make all absolute positioned elements inside it refer to it instead of 
the body, and make text align correctly since it is 'centered' on body 
for those old browsers.


You'll have to fine-tune some positions on elements in there, since you 
had compensated for body-margin-defaults instead of zeroing out those 
defaults.


Get rid of that javascript at the bottom of the markup, as Firefox 
doesn't like it one bit. If you want to use javascript; link to the 
files in the page-head.

regards
	Georg
-- 
http://www.gunlaug.no
______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
IE7b2 testing hub -- http://css-discuss.incutio.com/?page=IE7
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Previous Message
Next Message

Message thread: