I'm trying to make a header and footer in css. Following is my code:
HTML
<div id="container">
<div id="header">Kaboom!</div>
<div id="footer">Kaboom!</div>
</div>
CSS
#header{
background-color:orange;
width:500px;
height:20px;
border:3px solid blue;
border-left-style:none;
border-right-style:none;
list-style-type:none;
border-top-style:none;
text-align:center;
}
#footer{
margin-top:455px;
background-color:pink;
width:500px;
height:20px;
border:3px solid blue;
border-left-style:none;
border-right-style:none;
list-style-type:none;
border-bottom-style:none;
text-align:center;
}
#container
{
margin:auto;
background-color:#addadd;
width:500px;
height:500px;
border:5px solid blue;
border-radius:5px;
}
Although My code is working fine that is header is fitted at the top and footer at bottom. But I had to do many things manual for example I had to remove borders from inner elements, similarly I had to set margins by build and try method. My Question is that is there exist some mathematics here that is if container height and width is 500px then to fix elements inside it they should have some plus or minus pixels relative to the container. Similarly from what margin the header should be placed and at what margin relative to the container the footer be placed or is there some other efficient method?