Mijn site wil niet centreren, als ik dit aangeef in css.

Status
Niet open voor verdere reacties.

Rozenknopje

Gebruiker
Lid geworden
25 jun 2007
Berichten
46
Hoooi,

Ik was al een tijdje bezig met websites maken en ik wil graag css erbij. Nou heb ik hier voor een tutorial gevolgd, en is dit uiteindelijk mijn css code geworden:

Code:
body {[B][U]text-align: center;[/U][/B] margin: 0px; background: url('/bg.jpg') repeat-x #00000D; font-family: Verdana}
div#header {background: url('header.jpg') no-repeat; height: 435px; width: 650px}
div.content {width: 650px}
h2 {font-size: 24px; font-weight: bold; color: #FFFFFF}
div#posts {text-align: justify; width: 375px; color: #404051; font-size: 11px; line-height: 160%; float: left}
div#sidebar {background-color: #050418; width: 200px; font-size: 10px; color: #404051; text-align: justify; padding: 15px; line-height: 160%; float: right}
div.footer {width: 650px; height: 100px; color: #404051}

Alleen wil mijn site niet centreren, hij blijft links staan. Zoals je kan zien, in de eerste regel (dit heb ik onderstreept) van mijn css bestand, heb ik text-align: center staan. Als het goed is zou dit gewoon de hele site moeten centreren.

Het zou dezelfde werking moeten hebben als <center></center> tags.

Wat doe ik hier verkeerd?
Alvast bedankt!!

PS: Het css bestand is gewoon gekoppeld met het index bestand, want de rest werkt wel.
 
Container gebruiken:

Code:
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
	<title>(Type a title for your page here)</title>
<!--Pagina gemaakt op Sunday, May 17, 2009 17:30:18 -->
<meta name="GENERATOR" content="Arachnophilia 4.0">
<meta name="FORMATTER" content="Arachnophilia 4.0">
<meta name="description"  content="korte beschrijving van de pagina">
<meta name="keywords"  content="trefwoorden, die, slaan, op, de, pagina">
<meta name="publisher" content="Jan Jansen">
<meta name="Author" content="Peter Vazed">
<meta name="robots" content="index, follow">
<meta name="revisit" content="7 days">
<meta http-equiv=content-type content="text/html; charset=windows-1252">
<meta http-equiv="Content-Style-Type" content="text/css">

 <style type="text/css" media="screen">
body {  text-align:center;background: url('/bg.jpg') repeat-x #b0b474; font-family: Verdana}

#container{
margin-left:auto;
margin-right:auto;
width:100%;
border:2px solid #ff0000;

}
div#header {background: url('header.jpg') no-repeat; height: 435px; width: 650px;border:2px solid #ff0000;}
div.content {width: 650px;border:2px solid #ff0000;}
h2 {font-size: 24px; font-weight: bold; color: #FFFFFF}
div#posts {text-align: justify; width: 375px; color: #404051; font-size: 11px; line-height: 160%; float: left}
div#sidebar {background-color: #ff8000; width: 200px; font-size: 10px; color: #404051; text-align: justify; padding: 15px; line-height: 160%; float: right}
div.footer {width: 650px; height: 100px; color: #404051}
</style>
</head>

<body >
<div id="container">container
<div id="header">header</div>

<div class="content"><h1>content</h1> 
<div id="sidebar">sidebar</div>
<div id="posts">posts</div>
</div>



<div class="footer">footer</div>

</div>
</body>

</html>

:cool:

/// Rimsic was me net voor :)
 
Laatst bewerkt:
Het is me gelukt. Ik moest inderdaad aparte divs maken waar de site in zou komen te staan, en deze vervolgens centreren in CSS.

Dankjewel!! :D
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan