Hi all,
Im trying to learn, more so get a good solid understanding of how floating / positioning elements with CSS can be achieved.
I do already have some basic knowledge but getting my head around block/inline level elements and parent/child relationships is becoming somewhat a nightmare!
Please have a look at a very basic test page Ive knocked up to try and get to grips with the CSS. With this particular example, Im trying to set the #container <div> element set within the background colours - All background colours have been set at the same height as the containing div elements ( header / navigation / content and footer ).
I know I can quite easily put margin-top:-1005px; under the #container selector but this is bad practise, and would like to position it hopefully using floats or positioning styling…
I glady await to hear off anybody with expertise in this area, and would be absolutley thrilled if anyone could lend a hand, and more so explain there theories to me - “More knowledge = More Brain food”
I will put the HTML on first followed by the CSS coding.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Learning CSS</title>
<link rel="stylesheet" type="text/css" href="test.css" />
</head>
<body>
<div id="backgroundheader">
</div>
<div id="backgroundnavigation">
</div>
<div id="backgroundcontent">
</div>
<div id="backgroundfooter">
</div>
<div id="container">
<div id="header">
</div><!--header-->
<div id="navigation">
</div><!--navigation-->
<div id="content">
</div><!--content-->
<div id="footer">
</div><!--footer-->
</div> <!-- Container -->
</body>
</html>
/RESET STARTS HERE/
html, body{
margin: 0;
padding: 0; }
/*RESET ENDS HERE*/
#backgroundheader{
background:#0000ff;
width:100%;
height:100px;
border:1px solid black; }
#backgroundnavigation{
background:#eee;
width:100%;
height:50px;
border:1px solid black; }
#backgroundcontent{
background:#3366ff;
width:100%;
height:800px;
border:1px solid black; }
#backgroundfooter{
background:#eee;
width:100%;
height:50px;
border:1px solid black; }
#container{
border:1px solid black;
width:900px;
height:1005px;
margin:auto; }
#header{
width:900px;
height:100px;
border:1px solid black; }
#navigation{
width:900px;
height:50px;
border:1px solid black; }
#content{
width:900px;
height:800px;
border:1px solid black; }
#footer{
width:900px;
height:50px;
border:1px solid black; }
Thanks once again & I forward to hearing from anyone.
Benisjamin