Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

shing_shing's avatar

DOMPDF BACKGROUND IMAGE

Good day, Laracasts!

I did my best. But, I guess my best wasn't good enough! lol. Kidding aside.

I've been looking for ways to fix this since last week but now am hopeless.

This photo https://drive.google.com/file/d/1i3cooX7Gkf8EdEXp6zrXCwlrAVCVP4_s/view?usp=sharing : Is displaying how i wanted it to be displayed. This photo ran on my local pc usng dompdf.

And this photo on the other hand, https://drive.google.com/file/d/12n3xOALmsIa4vGgiD2ZndkxkI0-0eGWv/view?usp=sharing : Isn't. This photo through web, (cpanel or what we always call it---Cloud or Online).

What's supposed to be the problem here? Both were using dompdf. I use the code below:

            <div style="bottom: 0; border: 3px solid #72aeb5; margin-top: 30%; margin-left: 20%; margin-right: 20%; background-color: white; height: 200px;">
                            <table style="width: 100%; margin: 20px; text-align: center;">
                                        <tr>
                                            <td style="border-bottom: 1px solid black; font-weight: bold;">&nbsp;</td>
                                        </tr>
                                        <tr>
                                           <td>Pupil's Name</td>
                                        </tr>
                                        <tr>
                                            <td>&nbsp;</td>
                                        </tr>
                                        <tr>
                                            <td style="font-weight: bold;"><u></u></td>
                                        </tr>
                                        <tr>
                                            <td>Age as of October 31</td>
                                        </tr>
                                        <tr>
                                            <td>&nbsp;</td>
                                        </tr>
                                        <tr>
                                            <td style="font-weight: bold;"><u></u></td>
                                        </tr>
                                        <tr>
                                            <td>Sex</td>
                                        </tr>
                               </table>
                    </div>
 </div>```
0 likes
3 replies
jlrdw's avatar

Of course double-check make sure the code is the same but also you can try setting your viewport if you didn't:

<meta name="viewport" content="width=device-width, initial-scale=1">
shing_shing's avatar

I appreciate your immediate response, Sir @jlrdw. However, as I double checked my code, <meta name="viewport" content="width=device-width, initial-scale=1"> was already there.

jlrdw's avatar

Try less margin or adjust division, and is it the same browser you use in development.

Some browsers may have slight variations on how they handle things.

Please or to participate in this conversation.