Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Page-break-inside:avoid not working

Tags:

I have a print stylesheet for my (Wordpress) site, and I want images to print on a single page rather than being split across pages. In some cases, even lines of text are being split across pages. I've included img {page-break: avoid;) in my print stylesheet, but no luck. I've found some previous answers but they're kind of old.

Is there a reliable way to print a moderately-sized image on a single page rather than splitting it across pages? Why are lines of text breaking across pages?

picture broken across two pages

lines breaking across pages

Site: http://74.220.217.211/housing-developments/grafton-townhomes/

Related posts:

  • Print styles: How to ensure image doesn't span a page break

  • What are most useful media="print" specfic ,cross browser compatible css properties?

  • What is the correct way to do the CSS to avoid page breaks?

  • page-break-inside doesn't work in Chrome?
  • Work around for page-break-inside:avoid
like image 874
Katie Fritz Avatar asked Dec 30 '15 17:12

Katie Fritz


People also ask

How do I avoid a page-break inside?

The page-break-inside property sets whether a page-break should be avoided inside a specified element. Tip: The properties: page-break-before, page-break-after and page-break-inside help to define how a document should behave when printed. Note: You cannot use this property on absolutely positioned elements.

How does page-break inside work?

The page-break-inside property in CSS is used to specify how the page breaks inside the element to which it is applied while printing. It inserts a page break or sometimes it used to avoid page break inside an element while printing. Property Values: auto: It is the default value.

What is page-break After avoid?

always − A page break should be forced after this element's box. avoid − No page break should be placed after the element's box if at all possible. left − Force one or two page breaks after the element's box, such that the next page on which an element is printed will be a left-hand page.


1 Answers

It could be that the parent element of the img element has style:

display: flex 

Then the break-inside doesn’t work.

For example if you change parent element display style to:

display: block 

Then it will work.

like image 86
Kristjan Retter Avatar answered Sep 19 '22 11:09

Kristjan Retter