Do not break content inside div

2.4k views Asked by At

How do I tell mpdf to move div content to next page instead of breaking it in the middle? I found some mpdf-specific tags but it did not help me. Any ideas?

<div> <!-- content inside div should not be broken -->
    <h1>Heading</h1>
    <ul>
        <li n:foreach="$teacherSummary as $teacher => $children">
            {$teacher}: {array_unique($children)|implode:', '}
        </li>
    </ul>
    <p><strong>{$event->note}</strong></p>
</div>
1

There are 1 answers

0
Northys On BEST ANSWER

There is CSS property page-break-inside that works in mpdf as well.

Usage:

<div style="page-break-inside:avoid !important;">
    <h1>Heading</h1>
    <ul>
        <li n:foreach="$teacherSummary as $teacher => $children">
            {$teacher}: {array_unique($children)|implode:', '}
        </li>
    </ul>
    <p><strong>{$event->note}</strong></p>
</div>