Forum


Replies: 6   Views: 4224
Trying to keep on the same page with html: text and image with breaks between
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by wcalhoun  · 17-08-2015 - 18:19

I am trying to find a way to keep a block of content on the same page that goes like this: Text Image Text So I have text, then a new line, then an image, then a new line, then more text. Here is what I currently have: CSS: .figure{ text-align: center; page-break-after: avoid; } .figure span{ display: block; } HTML: <p class="figure"> <span>Text 1</span> <span><img src="path_to_image.jpg"></span> <span>Text 2</span> </p> This is working to keep the block on the same page, but the problem is, if 'Text 1' and the image can fit on the same line, it does that and doesn't cause a line break. I even tried manually putting <br> between Text 1 and the image and it still doesn't work.