html - Creating perfectly fitted header and footer elements inside div element -


I am trying to create a header and footer in CSS. The following is my code:

HTML

  & lt; Div id = "container" & gt; & Lt; Div id = "header" & gt; Cobum! & Lt; / Div & gt; & Lt; Div id = "footer" & gt; Cobum! & Lt; / Div & gt; & Lt; / Div & gt;  

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, which is located at the top, at the top and below the footer. But I had to do a lot for manual, for example I had to remove the boundaries from the internal elements, in the same way I had to set the margin through construction and try the method. My question is that here there are some maths That is, if the height and width of the container are 500 px, then in order to determine the element within it, they need some plus or minus pixels relative to the container. Similarly, what margin should be kept at the top of the margin and what is the foothold in container related margins or is there any other efficient method?

about it, position: # relative to the container, and then position: for the footer and header complete.

# Container {Status: Absolute; Margins: Auto; Background color: #addadd; Width: 500px; Height: 500px; Border: 2px solid blue; } # Headers {Position: Absolute; Background color: orange; Top: 0; Width: 500px; Height: 20px; Border bottom: 2px solid blue; Text-align: center; } #footer {status: complete; Bottom: 0; Background color: pink; Border-top: 2px solid blue; Width: 100%; Height: 20px; }


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -