且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Safari的page-break-inside:避免不起作用

更新时间:2023-12-06 10:07:34

尝试使用display: inline-block;而不是page-break-inside: avoid;.您可能还想添加vertical-align: top;width: 100%;以使元素的行为类似于普通块元素,而不是内联元素.

Try using display: inline-block; instead of page-break-inside: avoid;. You may also want to add vertical-align: top; and width: 100%; to make the elements behave like normal block elements instead of inline elements.

早在大多数浏览器中实现page-break-inside: avoid;之前,该技术就一直可靠地起作用.仍然是防止内容块中的页面中断的最可靠的跨平台方法.

This technique has been working reliably since long before page-break-inside: avoid; was implemented in most browsers. It's still the most reliable cross-platform way to prevent page breaks in a block of content.

如果要使表不可破坏,可以在其上设置display: inline-table;.或者,您也可以将其放在嵌入式块div中.

If you want to make a table unbreakable, you can set display: inline-table; on it. Or you can just put it in an inline-block div.