page-break-inside doesn't work in Chrome?

前端 未结 11 1424
夕颜
夕颜 2020-12-05 17:32

I have a bunch of paragraphs on a page:

...

...

...

The CSS rule for those p

11条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-05 17:55

    I know this is an old question but Chrome has changed since it was originally answered and this may help.

    It looks like page-break-inside:avoid works in Chrome based on the height of the element, so if you are floating a bunch of elements in a div, page-break-inside:avoid will not work.

    It's possible to get around this by explicitly defining the height the element you don't want broken up. jQuery example:

    $('#page_break_inside_avoid_element').height($('#page_break_inside_avoid_element').height());
    

提交回复
热议问题