Fixed size DIV with CSS (generate PDF with MPDF)

Asked

Viewed 227 times

0

I need a DIV with fixed size in centimeters width:12.5cm; and height:7.5cm;. I can keep these sizes when loading the view, but when I use PHP’s mPDF class, it ignores the height and increases it according to content. I need that regardless of the content, the size is maintained, even if for that the content goes over the edges.

CSS I’m using in DIV:

.container-ficha {
        background-color:#ffffff;
        width:12.5cm;
        height:7.5cm;
        border:1px solid black;
        margin: 0 auto 0 auto;
    }

L

2 answers

0

The solution I found was to add position:fixed; the class .container-ficha. In so doing he obeyed the width and height.

0

CSS works in the form of cascades, that is, by hierarchies.

try to use the code !important in their properties which must not be overwritten.

example:

 .container-ficha {
            background-color:#ffffff;
            width:12.5cm !important;
            height:7.5cm !important;
            border:1px solid black;
            margin: 0 auto 0 auto;
        }
  • Thanks for the answer! I tried here, but still it ignores the height. It only happens when generating the PDF, if you let it generate the common view, it works perfectly.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.