Is it possible to print header and footer in all pages of a html document using css without overlapping the header and content. I have tried "position:fixed" but with that the header overlaps with the body content. When I tried to set "top:margin" to the body of content it get applied only to the first page.
Code Sample
<html>
<head>
<style>
div#myheader {
position: fixed; top: 0; left: 0; width: 100%; height: 2em;
padding-bottom: 3em;
margin-bottom: 10px;
}
@media screen {
div#myheader {
display: none !important;
}
div#mainContent {
margin-top: 0;
}
}
@media print {
div#myheader {
display: block;
}
div#mainContent {
margin-top: 0em;
}
}
</style>
</head>
<body>
<div id="myheader" class="header" style="display: block;">
Header
</div>
<div id="mainContent">
// Have more than 150 lines here
</div>
</body>
</html>
Note: Please don't mark the question as duplicate. I saw similar questions in Stack Overflow and other blogs. But nothing helped me. I have been struck with this for nearly a month. Please comment your solutions.