Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css pdf page - header overlapping with content

enter image description here

As we can see from the image my content overlaps with the header image and this is the code I have:

    <style type="text/css" media="print">
        @page {
            /*size:landscape;*/

            @top-center {
                content: element(header);
            }
            @bottom-left {
                content: element(footer);
            }
        }
        div.header {
            padding: 10px;
            position: running(header);
        }
        div.footer {
            display: block;
            padding: 5px;
            position: running(footer);
        }
        .pagenumber:before {
            content: counter(page);
        }
        .pagecount:before {
            content: counter(pages);
        }
    </style>
</head>
<div class="header">
    <img src="logo.png" title="logo" width="200px"/>
</div>
<div class="content">

</div>

P.S.: Please don't close this question as duplicate as I have already searched all the questions related to the same but mine looks different as PDF is involved.

like image 504
javanoob Avatar asked Jul 16 '15 19:07

javanoob


People also ask

Why are my elements overlapping CSS?

Elements can overlap for a variety of reasons, for instance, relative positioning has nudged it over something else. Negative margin has pulled the element over another. Absolutely positioned elements overlap each other.

How do I stop the overlapping footer in CSS?

The only way to give them some space between the content and the footer is to remove that custom css and then add a bottom padding in the last section element. Right now, the bottom padding is 0 which is why it is close or overlapping to the footer.

Why are my HTML sections overlapping?

This could happen for several reasons, especially when you consider the position problems with divs from one website to another. Similarly, box elements may overlap for a few reasons, ranging from positioning errors to overflow issues and simple float problems.


1 Answers

Headers and footers are established within the page margins.

So the solution is to increase the page top margin, for example:

@page {
        margin-top: 50mm; 
}
like image 53
obourgain Avatar answered Sep 18 '22 23:09

obourgain