05-26-2021, 01:52 PM | #1 |
A Hairy Wizard
Posts: 3,101
Karma: 18727053
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
Centering text on screen vertically
Hi all,
Until now I've been using table properties to vertically center items (title, dedication, etc.) on the page. That works on my iOS reader of choice, but I've been told that table properties aren't handled very well on other/older devices. Spoiler:
Soooo, I was kinda thinking around about the vh property and tying the top margin of a div to being 33vh with the div height being 33vh (so the div encompasses the middle third of the screen height. That also seems to work - it's supported by all browsers, and it displays fine on Sigil - but I was wondering if anyone had experience with vh support "out in the wild"?? Or is it a case of the other/older devices that don't support table properties don't support vh either??? Spoiler:
Last edited by Turtle91; 05-26-2021 at 01:55 PM. |
05-26-2021, 01:58 PM | #2 |
frumious Bandersnatch
Posts: 7,516
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
It might work in some, I'm pretty sure it won't in many/most. It's not a required CSS property in ePub 2, so don't rely on it.
|
05-26-2021, 02:14 PM | #3 |
A Hairy Wizard
Posts: 3,101
Karma: 18727053
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
hmmm...that sucks....kinda what I was expecting, but still sucks. At some point I hope the industry gives up on the older devices and moves ahead with new technology...
Thanks! |
05-26-2021, 05:16 PM | #4 | |
Resident Curmudgeon
Posts: 74,037
Karma: 129333114
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
The problem is two-fold. Older devices that are still in use and companies that are not going to update the reading software or the reading software is updated but just is lacking features. There's no way to know what your reader is going to use to read the eBook with. So you have to go with the lowest common denominator. |
|
05-27-2021, 02:58 AM | #5 |
frumious Bandersnatch
Posts: 7,516
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
... or downgrade gracefully. Say, use vh inside a @supports block, and let the block just not be centered if it's not supported (assuming devices that don't support @supports will simply ignore it, and not choke and barf).
|
05-28-2021, 03:32 AM | #6 |
Obsessively Dedicated...
Posts: 3,200
Karma: 34977896
Join Date: May 2011
Location: JAPAN (US expatriate)
Device: Sony PRS-T2, ADE on PC
|
I gave up trying for vertical centering long ago, and rely on simply using a fairly large top margin or top padding. White space of 8em or 10em (or more) at the top of the page can be sufficient to dramatically set off your title, even if it does lack the cool factor of centering.
(but hobbiests like me can get away with that stuff.) Last edited by GrannyGrump; 05-28-2021 at 03:35 AM. |
05-28-2021, 02:01 PM | #7 |
A Hairy Wizard
Posts: 3,101
Karma: 18727053
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
I totally get that technique… my problem with it was not knowing what size display it would be read on… a large display, a few empty lines weren’t enough, a small display could cause it to roll to the next page!
The other benefit I saw in my experiment with vh was that I could adjust the font size dynamically… without js… it certainly wasn’t perfect, but it was pretty cool. Alas, it’s just a fun experiment if devices aren’t supporting it. Unless maybe using the @supports with a graceful downgrade as jelby mentioned |
05-28-2021, 03:23 PM | #8 | |
Resident Curmudgeon
Posts: 74,037
Karma: 129333114
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
|
|
05-28-2021, 04:56 PM | #9 |
Bibliophagist
Posts: 35,513
Karma: 145557716
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Forma, Clara HD, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Not very well. I once spent a weekend playing with various methods of trying to—approximately—vertically center a text box depending on the size of the screen. An exercise in futility since I couldn't manage to get the mix of media queries, @supports and a few other oddments to give me a result that looks close to what I wanted across my collection of ereaders and apps.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
SVG not centering vertically | Turtle91 | Sigil | 6 | 01-09-2020 03:43 PM |
Positioning text vertically on a page | Nabodita | ePub | 21 | 07-04-2017 06:52 AM |
Centering Text in Middle of Display Screen | oiver55 | Sigil | 16 | 04-23-2015 12:34 PM |
How do you vertically center a text? | Julius Caesar | Workshop | 9 | 09-08-2013 02:58 PM |
How do you center text vertically? | 44reader | ePub | 8 | 08-06-2012 01:52 PM |