CSS / HTML

Permabanned
Joined
19 Apr 2006
Posts
2,333
Location
West Yorkshire
Ok now for a css/html related question;

I have this in a php file:

Code:
<?php

echo '

<html>
<head>
<title>Darrens Test</title>

<link href="test.css" type="text/css" rel="stylesheet" />

</head>

<body>


<div id="container" align="center">
';

include("header.php");
include("leftnav.php");
include("body.php");
include("footer.php");

echo ' </div>

</body>
</html>
';

?>

and this in my css file:

Code:
body {
	font : 11px Verdana;
	color : #FFFFFF;
	background-color : #2c2b2b;
}

div#container {
	background-color : #FF0000;
	align : center;
	width : 800px;
	height : 600px;
	margin : 0;
	padding : 0;

}

but the container div is not lining up in the center of the page, everything else is right, but it doesnt sit in the center.

Thanks again guys, you knowledge is a valuable resource to me :)
 
Change margin: 0; to margin: 0 auto; for #container.

Also, you don't need those echo statements in your PHP, just drop in/out of PHP processing as necessary using the <?php ?> tags:

Code:
<html>
<head>
<title>Darrens Test</title>
<link href="test.css" type="text/css" rel="stylesheet" />
</head>
<body>

<div id="container" align="center">

<?php

include("header.php");
include("leftnav.php");
include("body.php");
include("footer.php");

?>

</div>

</body>
</html>
 
Augmented said:
Change margin: 0; to margin: 0 auto; for #container.

Also, you don't need those echo statements in your PHP, just drop in/out of PHP processing as necessary using the <?php ?> tags:
I remember when I first starting using php - I wasted so much time with unecesarry echo's and replacing all the "'s with \"'s :o
 
Thanks guys, that margin worked a treat.

Although can some explain the margin and padding thing to me?

I could have played with that code all night and never would have guessed at it being a margin I would have to change.
 
Back
Top Bottom