Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 07-12-2025, 11:05 AM   #1
Slevin#7
Connoisseur
Slevin#7 began at the beginning.
 
Posts: 61
Karma: 10
Join Date: May 2025
Device: iPad
Is it Safe to Use height: 100vh?

In some cases I wanna center images vertically on a single page. For that reason I set page-break-before and after on the container and center the image via flex.

HTML
Code:
<div class="single-page v-center">
  <figure>
    <img src="../images/aloha.png"/>
  </figure>
</div>
CSS
Code:
.single-page {
  -webkit-column-break-before: always;
            page-break-before: always;
                 break-before: always;
   -webkit-column-break-after: always;
             page-break-after: always;
                  break-after: always;
}

.single-page.v-center {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
}
Now, my question is, are there any downsides using the full 100vh, since I've seen some people using 98vh for whatever reason?

Also, I've noticed that Thorium (at least the version I'm running) doesn't recognize the page-break properties, but still uses the full 100vh for the conainer, which results in a container with the expected height but the container is split into two parts over two pages, while the image itself is put on the second page, overlaying text which is not nudged bottomwards. The space reserved is correct with 100vh, but it's not reserved on a single page, while the image is then taken out of the flow and put onto the second page. Really bad.

However, all other reader I've tested (Google, Apple, Calibre, PocketBook) seem to work well.

I'm grateful for any opinion on that.
Thanks
Slevin#7 is offline   Reply With Quote
Old 07-12-2025, 11:10 AM   #2
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 79,740
Karma: 145864619
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
It's not a good idea to with hv or wv if you want ePub2 compatibility. If you don't care about ePub2 compatibility, you can use vh and vw,

Last edited by JSWolf; 07-12-2025 at 04:43 PM.
JSWolf is offline   Reply With Quote
Old 07-12-2025, 11:22 AM   #3
Slevin#7
Connoisseur
Slevin#7 began at the beginning.
 
Posts: 61
Karma: 10
Join Date: May 2025
Device: iPad
Quote:
Originally Posted by JSWolf View Post
It's not a good idea to with hv or wv if you want ePub2 compatibility. If you don't care about ePub2 compatibility, you can use hv and wv,
Afaik, EPUB2 would simply ignore the vh, since it just doesn't know about, right? And since flex also isn't supported by EPUB2, it just shouldn't do anything but displaying the content in its normal flow.

Btw, is that a typo in your answer with hv and wv, or are these proper units?
Slevin#7 is offline   Reply With Quote
Old 07-12-2025, 03:10 PM   #4
RbnJrg
Wizard
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 1,762
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by Slevin#7 View Post
...
I'm grateful for any opinion on that.
Thanks
You don't need page-breaks if you work under epub3; watch the attached epub. Try to increase/decrease the font-size to see what happens.
Attached Files
File Type: epub Full Image by Flex and SVG.epub (297.3 KB, 17 views)

Last edited by RbnJrg; 07-12-2025 at 03:15 PM.
RbnJrg is offline   Reply With Quote
Old 07-12-2025, 03:14 PM   #5
RbnJrg
Wizard
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 1,762
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by Slevin#7 View Post
Btw, is that a typo in your answer with hv and wv, or are these proper units?
JSWolf made a typo; the right units are vh (viewport-height) and vw (viewport-width).
RbnJrg is offline   Reply With Quote
Old 07-12-2025, 04:42 PM   #6
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 79,740
Karma: 145864619
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by Slevin#7 View Post
Afaik, EPUB2 would simply ignore the vh, since it just doesn't know about, right? And since flex also isn't supported by EPUB2, it just shouldn't do anything but displaying the content in its normal flow.

Btw, is that a typo in your answer with hv and wv, or are these proper units?
If you did something like
Code:
.height {
height: 100%;
height: 100vh;
}
the last height line would be the one used or ignored. Same goes for ePub3. So if you want ePub2 compatibility, vh and vw have to go. You cannot use them.

Last edited by JSWolf; 07-12-2025 at 04:46 PM.
JSWolf is offline   Reply With Quote
Old 07-12-2025, 04:45 PM   #7
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 79,740
Karma: 145864619
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by RbnJrg View Post
JSWolf made a typo; the right units are vh (viewport-height) and vw (viewport-width).
Thanks for catching the typo. I've fixed it.
JSWolf is offline   Reply With Quote
Old 07-13-2025, 04:46 AM   #8
Quoth
Still reading
Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.
 
Quoth's Avatar
 
Posts: 14,010
Karma: 105092227
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper
Quote:
Originally Posted by JSWolf View Post
If you did something like
Code:
.height {
height: 100%;
height: 100vh;
}
the last height line would be the one used or ignored. Same goes for ePub3. So if you want ePub2 compatibility, vh and vw have to go. You cannot use them.
Or even maybe two sets of CSS?
Quoth is offline   Reply With Quote
Old 07-13-2025, 10:07 AM   #9
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,347
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
Yes, he could just use 2 css sheets.

I think JSWolfe's understanding of CSS is tainted by his experience with ADE. He thinks that the use of anything not understood/supported will cause the entire css sheet to be ignored, instead of just that portion that is not understood/supported. That is a valid concern under ADE but it is not a CSS issue. The portion below in red is an ADE issue not a css issue.

Quote:
If you did something like
Code:
.height {
height: 100%;
height: 100vh;
}
the last height line would be the one used or ignored. Same goes for ePub3. So if you want ePub2 compatibility, vh and vw have to go. You cannot use them.
Instead, he should have said something like this:

Quote:
Under ePub2
If you did something like
Code:
.height {
height: 100%;  /*accepted: height = 100%/*
height: 100vh; /*rejected - vh not supported: height remains = 100%/*
}
The last height line would be ignored because vh is not supported/understood.

Under ePub3
If you did something like
Code:
.height {
height: 100%;  /*accepted: height = 100%/*
height: 100vh; /*accepted - vh supported: height = 100vh/*
}
The last height line would be used because vh is supported and it is the most recent css following css heirarchy rules (height would be set to 100vh instead of 100%).
Unfortunately ADE (old decrepit version) is not the only device/app that doesn't follow css rules, so you must test your coding on the devices/apps that you are marketing.
Turtle91 is offline   Reply With Quote
Old 07-13-2025, 11:06 AM   #10
Falkor
Connoisseur
Falkor began at the beginning.
 
Posts: 89
Karma: 10
Join Date: Dec 2024
Device: Tolino Shine 5
Quote:
Originally Posted by Turtle91 View Post
Unfortunately ADE (old decrepit version) is not the only device/app that doesn't follow css rules, so you must test your coding on the devices/apps that you are marketing.
Current versions of ADE still have this problem, but only when opening epub2 files.
Falkor is offline   Reply With Quote
Old 07-13-2025, 12:01 PM   #11
RbnJrg
Wizard
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 1,762
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by Falkor View Post
Current versions of ADE still have this problem, but only when opening epub2 files.
That is because ADE 4 has two rendering engines: the old RMSDK to render epub2 and a Readium derivative for rendering epub3. That's why epub2 renders look the same in both ADE 2.x/3.x and ADE 4.x.
RbnJrg is offline   Reply With Quote
Old 07-13-2025, 03:21 PM   #12
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 79,740
Karma: 145864619
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by Turtle91 View Post
Yes, he could just use 2 css sheets.

I think JSWolfe's understanding of CSS is tainted by his experience with ADE. He thinks that the use of anything not understood/supported will cause the entire css sheet to be ignored, instead of just that portion that is not understood/supported. That is a valid concern under ADE but it is not a CSS issue. The portion below in red is an ADE issue not a css issue.
It's not because of ADE. It's because many programs that do not support ePub3 will not support vh and vw. And CSS works top down. So if you have two height lines like a posted, only the second one will be used. The first one will not be used. vh and vw are not considered an error in ADE. But the 100% will not work because the second height line will be used instead.

Also, using 2 style sheets will not always work. Not every ePub3 compatible program supports Javascript. So you have to treat your ePub like the program being used don't do Javascript.

Last edited by JSWolf; 07-13-2025 at 03:23 PM.
JSWolf is offline   Reply With Quote
Old 07-13-2025, 04:49 PM   #13
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,759
Karma: 5706256
Join Date: Nov 2009
Device: many
For the record, which true epub3 ereaders do not support even basic javascript?
KevinH is offline   Reply With Quote
Old 07-13-2025, 06:43 PM   #14
RbnJrg
Wizard
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 1,762
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
By the way, the OP could try using not only "vh" but also "svh" or "dvh" (for example, Sigil and its plugins, Thorium, Calibre Viewer, accept those units). Regarding units viewport there are much more than vh and wh:

https://www.terluinwebdesign.nl/en/b...h-svw-lvw-dvw/

https://caniuse.com/?search=svh

These new sv* units are especially useful for Android and iOS e-readers. One could try a style with:

Code:
.myHeight {
   height: 100vh;
}

@supports (height: 100svh) {
   .myHeight {
      height: 100svh;
   }
}
RbnJrg is offline   Reply With Quote
Old 07-13-2025, 10:25 PM   #15
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 31,047
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by Slevin#7 View Post
Afaik, EPUB2 would simply ignore the vh, since it just doesn't know about, right? And since flex also isn't supported by EPUB2, it just shouldn't do anything but displaying the content in its normal flow.

Btw, is that a typo in your answer with hv and wv, or are these proper units?
Some IGNOR THE WHOLE CSS when they disagree. Don't always believe the specs. They are only guidelines
theducks is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Image height JSWolf KOReader 6 03-29-2021 04:29 PM
Picture height senhal ePub 6 12-31-2018 03:07 PM
line height Rellwood Conversion 3 04-07-2018 04:34 AM
EuGH zu Safe Haven USA: Not safe enough. beachwanderer Deutsches Forum 0 10-06-2015 04:25 AM
Max-Height theducks Sigil 6 09-02-2010 05:40 PM


All times are GMT -4. The time now is 09:01 PM.


MobileRead.com is a privately owned, operated and funded community.