05-08-2018, 10:40 AM | #1 |
Zealot
Posts: 137
Karma: 10
Join Date: Sep 2016
Location: Montréal Québec
Device: Kobo Glo; Kobo Libra
|
Conditional CSS epub kepub
Is it possible to create CSS witch act conditionally to the format of the ebook: if ePub do this; if kepub do that?
|
05-08-2018, 11:45 AM | #2 |
Grand Sorcerer
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
No, not in the same way that Kindle books can have alternative CSS for MOBI and KF8 formats.
However, there is a trick you can use to make sure selected CSS will only be applied to kepub but not epub. Can you give an example of what CSS you're trying to use for each? How are you creating your kepubs? Do you use calibre to transfer books to your Kobo? |
Advert | |
|
05-08-2018, 12:39 PM | #3 |
Zealot
Posts: 137
Karma: 10
Join Date: Sep 2016
Location: Montréal Québec
Device: Kobo Glo; Kobo Libra
|
[QUOTE=No, not in the same way that Kindle books can have alternative CSS for MOBI and KF8 formats.
However, there is a trick you can use to make sure selected CSS will only be applied to kepub but not epub. Can you give an example of what CSS you're trying to use for each? How are you creating your kepubs? Do you use calibre to transfer books to your Kobo?[/QUOTE] I'm editing my epub books through Calibre and then transform them as kepub. But the epub and kepub format don't act the same in my Kobo. For example, my preference is to hide the footnotes (display: hidden) in the normal reading. There is no problem to view the footnotes in .kepub since it appears in a popup window, but the epub format won't display the footnote at all. |
05-08-2018, 03:39 PM | #4 |
Grand Sorcerer
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
Calibre's Check Book tool shows display:hidden as an error, perhaps it appeared in a later version of CSS than is typically supported by ADE-style renderers on eink devices, such Kobo's renderer for standard epubs.
I must admit I don't use any special CSS or markup for footnotes, I just use simple anchors which seem to work as expected on the Kobo, i.e. - kepub: choice of pop-up or link-to-endnotes page - epub: link-to-endnotes page only They work no matter whether the book is epub/kepub and no matter whether the kepub was created from an EPUB2 or an EPUB3. For example: Chapter HTML file: Code:
<p>... a rule instituted hundreds of years ago to prevent this branch of the Church becoming too big for its boots.<sup><a id="back02" href="endnotes.xhtml#fn02">[2]</a></sup> But ...</p> Code:
<p class="footnote"><a id="fn02" href="chapter1.xhtml#back02">[2]</a><br/>Which were of the one-size-fits-all, tighten-the-screws variety.</p> Code:
.footnote { margin: 0 0 0 2em; padding-top: 3em; text-indent: -1em; } sup { font-size: 0.9em; line-height: 0; vertical-align: super; } Last edited by jackie_w; 05-08-2018 at 04:07 PM. Reason: ETA |
05-08-2018, 04:44 PM | #5 | |
Zealot
Posts: 137
Karma: 10
Join Date: Sep 2016
Location: Montréal Québec
Device: Kobo Glo; Kobo Libra
|
Quote:
And this was 1 example of divergence code between epub and kepub. That's why I'm searching a way to toggle the CSS code between the 2. |
|
Advert | |
|
05-08-2018, 05:20 PM | #6 |
Grand Sorcerer
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
I'm not really sure what display:hidden is supposed to do, did you mean visibility:hidden? What happens if you try display:none instead for your footnote CSS? I think this is supported by the Kobo epub renderer.
If you want to exclude a whole file of endnotes you could try adding linear=no as an attribute in the spine <itemref> entry for the endnotes.xhtml file in the OPF file. |
05-08-2018, 05:29 PM | #7 | |
Bibliophagist
Posts: 36,424
Karma: 145748708
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Quote:
Code:
.hidden { display : none; } |
|
05-08-2018, 08:38 PM | #8 | |
Zealot
Posts: 137
Karma: 10
Join Date: Sep 2016
Location: Montréal Québec
Device: Kobo Glo; Kobo Libra
|
Quote:
To come back to my initial question: is it possible to toggle active/non-active a part of code specifically differentiated when the file is a epub or a kepub? |
|
05-08-2018, 11:02 PM | #9 |
Wizard
Posts: 3,821
Karma: 19162882
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
|
KePubs created by Calibre have a wrapper <div> with id="book-columns" inside <body>, so you should be able to use this to add KePub-specific CSS. E.g.:
Code:
/* ePub default */ span.mystyle { color: green; } /* KePub override */ div#book-columns span.mystyle { color: blue; } |
05-09-2018, 01:27 PM | #10 | |
Zealot
Posts: 137
Karma: 10
Join Date: Sep 2016
Location: Montréal Québec
Device: Kobo Glo; Kobo Libra
|
Quote:
.note { display: block; } div#book-columns .note { display: none; } without success. The footnote is still visible at the end of the chapter in the kepub file. My html code (using a footnote class "nbp") look like this: <div class="note"> <br/><hr width="33%"/> <p class="nbp">... |
|
05-09-2018, 04:51 PM | #11 |
Zealot
Posts: 137
Karma: 10
Join Date: Sep 2016
Location: Montréal Québec
Device: Kobo Glo; Kobo Libra
|
I tried also :
book-columns .note { display: none; } and div.book-columns .note { display: none; } Same result. |
05-09-2018, 07:24 PM | #12 |
Grand Sorcerer
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
|
Deleted
Last edited by jackie_w; 05-10-2018 at 04:28 AM. |
05-10-2018, 12:25 AM | #13 |
Wizard
Posts: 3,821
Karma: 19162882
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
|
That works on my Glo. How are you creating the KePub? You might try examining the .kepub.epub file after it has been sent to the device to check that Calibre has added the <div id="book-columns"> after <body>, older versions of the KoboTouchExtended driver didn't do this.
Last edited by GeoffR; 05-10-2018 at 12:30 AM. Reason: added closing " |
05-10-2018, 07:29 AM | #14 | |
Zealot
Posts: 137
Karma: 10
Join Date: Sep 2016
Location: Montréal Québec
Device: Kobo Glo; Kobo Libra
|
Quote:
|
|
05-12-2018, 09:29 AM | #15 | |
Librarian
Posts: 346
Karma: 72225
Join Date: Apr 2015
Location: Liège - Belgium
Device: kobo gloHD - KA1
|
Quote:
Or you can navigate your plugged kobo like a usb key, find your book within it open the book (a kepub since it's on kobo) with ebook-edit and change the css there. |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
kepub, (x)html and css | Sam Sahara | Kobo Reader | 2 | 12-23-2017 03:39 PM |
Loading a custom CSS on kepub opening | met67 | Kobo Developer's Corner | 51 | 02-11-2017 02:13 AM |
Creating epub/kepub books (docx→epub/kepub via MS Word→Calibre) | SJC-Caron | ePub | 18 | 04-21-2016 11:10 AM |
Conditional CSS for ADE readers | democrite | ePub | 4 | 09-23-2013 09:10 PM |
Conditional CSS rules | Jellby | ePub | 10 | 01-20-2009 08:32 AM |