| 
			
			 | 
		#1 | 
| 
			
			
			
			 Enthusiast 
			
			![]() Posts: 30 
				Karma: 10 
				Join Date: Apr 2025 
				
				
				
				Device: none 
				
				
				 | 
	
	
	
		
		
			
			 
				
				epub, images, and my codes
			 
			
			
			With my friend's help, I am making a reflowable epub in Sigil. One chapter has more than 350 definitions. Each definition has a heading and an explanation. More than 100 definitions also have an image. These definitions include a heading, an image, and an explanation. All images are full-width (width: 1200 pixels), and have a height between 300 and 900 pixels. No image has any caption. 
		
	
		
		
		
		
		
		
		
		
		
		
	
	Everything is working good. But we all know that images can create problems on different devices and apps, so I am trying to write the best code for images. Do I need to make any changes, adding or removing something, in these codes? CSS: img { display: block; width: 100%; height: auto; object-fit: contain; } .image-setup { text-indent: 0; text-align: center; margin: 0 auto; width: 99%; page-break-before: auto; page-break-inside: avoid; page-break-after: auto; } HTML: <p>text text text</p> <div class="image-setup"> <img src="image1.jpg" alt="beautiful image one"> </div> <p>text text text</p> Thanks for your time, your help and insights  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#2 | 
| 
			
			
			
			 Wizard 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,877 
				Karma: 8821117 
				Join Date: Mar 2013 
				Location: Rosario - Santa Fe - Argentina 
				
				
				Device: Kindle 4 NT 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			Well, althought we don't know if you are working with epub2 or epub3, I would employ the following code: 
		
	
		
		
		
		
		
		
		
		
		
		
	
	Code: 
	img {
  display: inline-block;
  width: 99%; /* or whatever width you wish */
}
.image-setup {
  text-indent: 0;
  text-align: center;
  margin: 0;
}
 | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#3 | 
| 
			
			
			
			 Enthusiast 
			
			![]() Posts: 30 
				Karma: 10 
				Join Date: Apr 2025 
				
				
				
				Device: none 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			I don't know why you removed all those, e.g., "page-break-inside: avoid", it helps so the image will not be split across two pages.  
		
	
		
		
		
		
		
		
		
		
		
		
	
	Please I need help from someone who is professional or knows what is best.  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#4 | 
| 
			
			
			
			 Bibliophagist 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 48,175 
				Karma: 174315444 
				Join Date: Jul 2010 
				Location: Vancouver 
				
				
				Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			If the image is too big to fit on a page, nothing will keep it from splitting. You might want to look at adding bits such as max-height and max-width. OTOH, since you appear to be using full page images with your splitting before and after, you may want to look at using an svg wrapper. 
		
	
		
		
		
		
		
		
		
		
		
		
		
			As for someone who is professional or knows editing epubs? I think you just insulted one of them. BTW, page-break-before and page-break-after are replaced by break-before and break-after. Last edited by DNSB; 05-01-2025 at 01:20 AM.  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#5 | ||
| 
			
			
			
			 Still reading 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 15,004 
				Karma: 111111255 
				Join Date: Jun 2017 
				Location: Ireland 
				
				
				Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper 
				
				
				 | 
	
	
	
		
		
		
		
		 Quote: 
	
 Quote: 
	
 I might not always agree with RbnJrg, but RbnJrg is very professional and expert.  | 
||
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#6 | |
| 
			
			
			
			 Wizard 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,877 
				Karma: 8821117 
				Join Date: Mar 2013 
				Location: Rosario - Santa Fe - Argentina 
				
				
				Device: Kindle 4 NT 
				
				
				 | 
	
	
	
		
		
		
		
		 Quote: 
	
   You don't need "page-break-inside: avoid" because in the img style I am employing "display: inline-block". That property avoids the split of the image. Try the code I posted and you will see it should work perfectly (with an image whose width is higher than his height; do the try with a with of 50% and you'll see how the image is centered without "margin: 0 auto"; that is also due to the property "display: inline-block" joined with the property "text-align: center" in the "image-setup" style). Of course, the img won't split but it can originate blank spaces; since we don't know if you are working under epub2 or epub3, I can't tell you how to avoid (if it were possible) those blank spaces. By the way, under epub3, "page-break-inside: avoid" is not honored by epub3 ereaders.And thank you very much DNSB and Quoth for your words about me; many thanks. Last edited by RbnJrg; 05-01-2025 at 09:38 AM.  | 
|
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#7 | 
| 
			
			
			
			 Resident Curmudgeon 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 80,782 
				Karma: 150249619 
				Join Date: Nov 2006 
				Location: Roslindale, Massachusetts 
				
				
				Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			Wouldn't the image have to split to the next screen it if did not fit on the space available on the screen?
		 
		
	
		
		
		
		
		
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#8 | ||
| 
			
			
			
			 A Hairy Wizard 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,397 
				Karma: 20212733 
				Join Date: Dec 2012 
				Location: Charleston, SC today 
				
				
				Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire 
				
				
				 | 
	
	
	
		
		
		
		
		 Quote: 
	
 Quote: 
	
  | 
||
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#9 | |
| 
			
			
			
			 Wizard 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,877 
				Karma: 8821117 
				Join Date: Mar 2013 
				Location: Rosario - Santa Fe - Argentina 
				
				
				Device: Kindle 4 NT 
				
				
				 | 
	
	
	
		
		
		
		
		 Quote: 
	
 The OP had employed in the "image-setup" style, the property "text-align: center" and in the img tag the property "display: block". But "text-align: center" is useless if an element is displayed as block. That one, only works for "inline" or "inline-block" elements. So to avoid properties "page-break-inside: avoid" and "margin: 0 auto", with "display: inline-block" the property "text-align: center" will work, the image always will be centered (no matter the width) and won't split. The code employed is minimun. Last edited by RbnJrg; 05-01-2025 at 10:48 AM.  | 
|
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#10 | |
| 
			
			
			
			 Resident Curmudgeon 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 80,782 
				Karma: 150249619 
				Join Date: Nov 2006 
				Location: Roslindale, Massachusetts 
				
				
				Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3 
				
				
				 | 
	
	
	
		
		
		
		
		 Quote: 
	
  | 
|
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#11 | 
| 
			
			
			
			 Enthusiast 
			
			![]() Posts: 30 
				Karma: 10 
				Join Date: Apr 2025 
				
				
				
				Device: none 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			RbnJrg......First and foremost, please accept my sincere apologies if I hurt you in any way. We are working on epub3, but if a platform only supports epub2, we will need to work on that too. I will definitely try your codes. Thanks a lot. And Thank You for the explanations. I really like this forum! 
		
	
		
		
		
		
		
		
		
		
		
		
	
	Quoth......You talked about a problem and said there is a solution, but you didn’t tell us what the solution is. Could you please share it?  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#12 | 
| 
			
			
			
			 Wizard 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,877 
				Karma: 8821117 
				Join Date: Mar 2013 
				Location: Rosario - Santa Fe - Argentina 
				
				
				Device: Kindle 4 NT 
				
				
				 | 
	
	|
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#13 | 
| 
			
			
			
			 frumious Bandersnatch 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,570 
				Karma: 20150435 
				Join Date: Jan 2008 
				Location: Spaniard in Sweden 
				
				
				Device: Cybook Orizon, Kobo Aura 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			Aren't you assuming a screen in portrait orientation? What if someone wants to read in landscape orientation (and I know someone who does)?
		 
		
	
		
		
		
		
		
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#14 | 
| 
			
			
			
			 Enthusiast 
			
			![]() Posts: 30 
				Karma: 10 
				Join Date: Apr 2025 
				
				
				
				Device: none 
				
				
				 | 
	
	|
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#15 | 
| 
			
			
			
			 A Hairy Wizard 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,397 
				Karma: 20212733 
				Join Date: Dec 2012 
				Location: Charleston, SC today 
				
				
				Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			Using ePub3 - if your targeted reader supports the css3 properties - you can use: 
		
	
		
		
		
		
		
		
		
		
		
		
		
			'object-fit: contain' as you mentioned, and maybe take a look at 'display: flex' . You would need to provide fallback coding for devices that don't support them. As DNSB mentioned, I use an svg wrapper that seems to be widely supported and works on ePub2/3 and doesn't care if the reading device is portrait or landscape, or if the image is wider than tall. But that really only works when you have an image taking up an entire page by itself. There are techniques to add text to the svg wrapper, but that is more in-depth. For your purposes I would stick with using the object-fit and display: flex for the ePub3 and fallback to the coding RbnJrg recommended. Example SVG wrapper: Code: 
	<html>
 <head>
    <title></title>     
    <style type="text/css">
        *   {margin:0; padding:0}
        div {width:100%; width:100vw; height:100%; height:100vh}
    </style>
</head>
<body>
<div>
  <svg 
    version="1.1"
    xmlns="http://www.w3.org/2000/svg"
    xmlns:xlink="http://www.w3.org/1999/xlink"
    width="573px" height="800px" 
    viewBox="0 0 573 800" 
    preserveAspectRatio="xMidYMid meet">
     <image width="573" height="800" xlink:href="../Images/your_img.png" />
  </svg>
</div>
</body> 
</html>
Last edited by Turtle91; 05-02-2025 at 07:48 AM.  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
![]()  | 
            
        
            
            
  | 
    
			 
			Similar Threads
		 | 
	||||
| Thread | Thread Starter | Forum | Replies | Last Post | 
| Word -> EPUB Chapter titles blank for Headings using Word's {TC...} codes | GranitStateColin | Conversion | 2 | 12-21-2021 10:29 PM | 
| images in epub | alberto_savoini | Tolino | 1 | 01-10-2020 01:33 AM | 
| Images exporting to epub | carlsbad | Workshop | 5 | 09-13-2014 03:10 AM | 
| Epub creation - pasting word and preserving codes | Mr Pointy | ePub | 24 | 03-21-2014 03:55 PM | 
| ePub with Images | prdufresne | Calibre | 10 | 12-04-2010 02:55 AM |