09-26-2024, 06:01 PM | #31 |
Resident Curmudgeon
Posts: 76,007
Karma: 134368292
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
|
09-26-2024, 11:39 PM | #32 |
Wizard
Posts: 1,603
Karma: 7999999
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
The best thing is that works If the ereader device can't read the javascript that links the css3 stylesheet to the xhtml files, then it means that is only an epub2 ereader and the css3 code never is loaded; in that case you have a perfect epub2 ebook On the other hand, if the javascript can be executed, then it means that we have an epub3 ereader, the css3 stylesheet is linked and the css2 classes are overwritten; you have a perfect epub3 ebook. Two epubs in only one ebook; the best of both worlds.
|
09-28-2024, 11:17 AM | #33 |
Wizard
Posts: 1,603
Karma: 7999999
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
For those who want to play with the idea of changing styles from css2 to css3 via javascript, I attach a simple epub that only contains a title page.
The epub is initially only linked to the epub2.css stylesheet and therefore the layout is pure epub2/css2. When the epub is loaded, if the e-reader is one that supports epub3, the script will be executed and link the epub3.css stylesheet. Since the styles in this stylesheet have the same name as the styles in the epub2.css and is linked later, the epub3 styles overwrite the epub2 ones and of this way the epub gives the best reading experience. In the example you can see how the title page improves when a flex-box is used. All texts are perfectly centered, both horizontally and vertically, and the layout is maintained regardless of the change in font size. This does not happen when the epub is opened in an e-reader that only supports epub2, since here, changes in font size strongly affect the layout. Try opening the epub first in ADE 2.x/3.x (or KOReader, that is a nice epub2 ereader) and then open this same epub for example in Calibre Viewer/Thorium/Readium. When you open it in ADE 2.x/3.x/KOReader only the code for epub2 is active and consequently the vertical centering is affected by the change in font size. On the other hand, when the epub is opened in Calibre Viewer/Thorium/Readium the code for epub3 is activated and the centering, both vertical and horizontal, is maintained regardless of the font size. In conclusion, the attached epub can be opened by an epub2 and epub3 e-reader. If it is opened by an epub2 device, only de epub2 code is enabled and the reader has a nice and old epub to read ; if it is opened by an epub3 device, then the epub3 code is enabled and overwrites the epub2, giving the best reading experience. In the epub you can also see the simple script that allows the linking of the code for epub3 when the book is opened. |
09-28-2024, 03:30 PM | #34 |
Resident Curmudgeon
Posts: 76,007
Karma: 134368292
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
What happens if this ePub is read initially with an ePub3 reader and the Javascript is executed. Then the ePub is read on an ePub2 reader. How does CSS2 get used since the CSS is now CSS3 from the previous view? Does the Javascript run when either the ePub is closed and/or the program is exited to put the CSS2 back in place?
Last edited by JSWolf; 09-28-2024 at 03:37 PM. |
09-28-2024, 03:40 PM | #35 |
A Hairy Wizard
Posts: 3,204
Karma: 19000001
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
|
Jon, the JavaScript doesn’t CHANGE the css… it simply attaches the new file when the epub is loaded on a device that runs js. If it doesn’t run js it doesn’t link the new css file.
The epub file doesn’t change at all between devices. |
09-28-2024, 03:52 PM | #36 |
A Hairy Wizard
Posts: 3,204
Karma: 19000001
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
|
Also, this js technique is not strictly necessary on a compliant device. Simply linking the ePub3 css file AFTER the ePub2 css file would work the same way. RbnJrg’s js technique protects against non-compliant devices/apps by only linking the ePub3 css if it can run js. Thus you wouldn’t have decrepit devices ignoring all the css if it didn’t like one. A compliant device would do this automatically by ignoring css it doesn’t support. This js technique can be used in multiple ways, however, and is a great step in learning “fall-back” coding theories.
Thanks RbnJrg |
09-28-2024, 06:08 PM | #37 | |
Wizard
Posts: 1,603
Karma: 7999999
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
Last edited by RbnJrg; 09-28-2024 at 06:21 PM. |
|
09-28-2024, 06:20 PM | #38 | ||||
Wizard
Posts: 1,603
Karma: 7999999
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
Quote:
Quote:
Quote:
|
||||
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Screen shady bottom | emreceng | Onyx Boox | 3 | 02-09-2020 01:15 PM |
Aura HD Lines on bottom of screen | hf.tan | Kobo Reader | 4 | 08-28-2014 08:02 PM |
Page numbers at bottom of screen | Waylander | Sony Reader | 1 | 10-18-2013 02:21 PM |
Circled M or S at the bottom of the screen | Larken | Sony Reader | 4 | 12-18-2009 03:15 PM |
Black line 3½ cm from bottom of screen | Moonraker | iRex | 6 | 08-20-2006 11:19 AM |