I always struggle with CSS layouts and positioning 'div' elements on the page. For instance, I have created the following structure:
Check out my jsfiddle: http://jsfiddle.net/JJw7c/3/
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Example</title>
</head>
<body>
<div class="container">
<div class="header">
this is the header
<div class="menu">
menu goes here
</div>
</div>
<div class="main">
main content goes here
</div>
</div>
<div class="footer">
footer
</div>
</body>
</html>
body
{
margin:10px;
}
.container
{
border:1px solid black;
min-height:400px;
width:100%;
}
.header
{
border:1px solid red;
height:100px;
}
.menu
{
border:1px solid green;
height:20px;
width:50%;
float:right;
}
.main
{
border:1px solid grey;
min-height:100px;
margin:20px;
}
.footer
{
border:1px solid green;
width:100%;
padding-top:10px;
}
Suppose I want to position an icon in the lower right corner of the header with precision. Should I use `position: relative` then `top: 20px`, or `position: absolute`? Or maybe `margin-right: 200px`? Could I utilize floats along with position absolute? <<< Please elaborate on when each approach should be used and if possible, update my jsfiddle with examples for each.
Thank you