![]() |
#1 |
Member
![]() Posts: 24
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,688
Karma: 8700123
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 |
Member
![]() Posts: 24
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: 45,520
Karma: 168929301
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 12:20 AM. |
![]() |
![]() |
![]() |
#5 | ||
Still reading
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,837
Karma: 103895653
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,688
Karma: 8700123
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
![]() And thank you very much DNSB and Quoth for your words about me; many thanks. Last edited by RbnJrg; 05-01-2025 at 08:38 AM. |
|
![]() |
![]() |
![]() |
#7 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,474
Karma: 145863170
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,335
Karma: 20171571
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,688
Karma: 8700123
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 09:48 AM. |
|
![]() |
![]() |
![]() |
#10 | |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,474
Karma: 145863170
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
|
|
![]() |
![]() |
![]() |
#11 |
Member
![]() Posts: 24
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,688
Karma: 8700123
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
|
![]() |
![]() |
![]() |
#13 |
frumious Bandersnatch
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,546
Karma: 19001583
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 |
Member
![]() Posts: 24
Karma: 10
Join Date: Apr 2025
Device: none
|
|
![]() |
![]() |
![]() |
#15 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,335
Karma: 20171571
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 06:48 AM. |
![]() |
![]() |
![]() |
|
![]() |
||||
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 09:29 PM |
images in epub | alberto_savoini | Tolino | 1 | 01-10-2020 12:33 AM |
Images exporting to epub | carlsbad | Workshop | 5 | 09-13-2014 02:10 AM |
Epub creation - pasting word and preserving codes | Mr Pointy | ePub | 24 | 03-21-2014 02:55 PM |
ePub with Images | prdufresne | Calibre | 10 | 12-04-2010 01:55 AM |