不要破坏div内的内容

时间:2015-06-17 16:26:35

标签: html css printing mpdf export-to-pdf

如何告诉mpdf将div内容移到下一页而不是在中间打破它?我发现了一些特定于mpdf的标签,但它对我没有帮助。有什么想法吗?

<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 个答案:

答案 0 :(得分:1)

CSS属性page-break-inside也适用于mpdf。

<强>用法

<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>