<div id="container">
<!-- your content in here -->
</div>
#container{width:800px; height:600px; padding:0; margin:0 auto;}
Mr_L said:You can create a container div which will hold most of your layout.
Code:<div id="container"> <!-- your content in here --> </div>
Then you would need the following CSS; -
Code:#container{width:800px; height:600px; padding:0; margin:0 auto;}
div#container {
position: absolute;
left: 50%;
margin-left: -360px;
}
body
{
text-align: center;
}
div#container
{
margin-left: auto;
margin-right: auto;
width: <your-width-here>;
text-align: left;
}
Scam said:Wrap everything in a container div.
CSSCode:div#container { position: absolute; left: 50%; margin-left: -360px; }
Using this method, where i have 360px it should be half of the width of the div. In fact looking at that code i've forgotton to put in a width. I wonder how that works thenlol! (It should be 720px there). Note thats it's minus half the width.
Thats the way i use, but i think the most common way is:
Code:body { text-align: center; } div#container { margin-left: auto; margin-right: auto; width: <your-width-here>; text-align: left; }
It's all in the margin-left/right: auto. The text-align: center on the body is just for old IE's that dont use the margin setting properly.
Also just to note, your container shouldnt be 800px, i think ~750px is the actual max to fit into a browser at 800x600 resolution.
EDIT: Well holy crap. Beaten by a country mile!![]()
Did i nod off mid-post or something? rofl!![]()
* {
margin: 0;
padding: 0;
}
body {
text-align: center;
}
div#container {
margin: 0 auto;
text-align: left;
width: 750px;
}
body {background-color: black }
{font-family: Verdana, Arial, Sans Serif; font-size: 12px; color: FFFFFF; }
a:link { text-decoration: none; }
a:hover { text-decoration: none; }
a:visited { text-decoration: none; }
a:link { color:#ffffff; }
a:visited { color:#ffffff; }
a:hover { color:#ffffff; }
a:active{ color:#ffffff; }
}
<html>
<head>
<LINK href="mc.css" rel="stylesheet" type="text/css">
</head>
<body>
MC R0x0rz
</body>
<iframe src="main.html" width="343" height="300" frameborder="0" allowTransparency="true"></iframe>
body {
background-color: #000;
color: #fff;
font-family: Verdana, Arial, Sans Serif;
font-size: 12px;
}
a:link, a:visited, a:hover, a:active {
color: #fff;
text-decoration: none;
}
Al Vallario said:Fix your CSS:
You had brackets all over the place, repetitive declarations, a missing hash etc. before. Much betterCode:body { background-color: #000; color: #fff; font-family: Verdana, Arial, Sans Serif; font-size: 12px; } a:link, a:visited, a:hover, a:active { color: #fff; text-decoration: none; }
![]()
iCraig said:Well, can you give us a link to the site so we can see?
iCraig said:Your IE is running in quirks mode, give it a doc type declaration.
Like this:
Code:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">