View Single Post
Old 04-02-2020, 01:49 PM   #2
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,252
Karma: 16544692
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
Quote:
Originally Posted by Simboubou View Post
Hello,

I have the habit to convert all my epubs to kepubs, with a unified format.
One thing I noticed (and found mentioned elsewhere on the forum), it that when using the "justified" mode on the kobo, Centering information (mostly on images) are messed up.

I know that one solution is to enforce justified text when converting books in calibre then turn justify Off on the kobo. But for some reasons I'd like to find a way not to have to do that on some books. I'm ok with editing books and using a regex-find-and-replace, but I'm not very good at css. Is there some property that I could inject that would center images even in kobo-justifed mode ?
First let me say that if you want to understand and control styling in your Kobo epubs/kepubs you really need to understand how HTML and CSS works. You don't need to be an expert but a basic understanding (and a willingness to learn more) is essential.

The problem you're running up against is the Kobo firmware's built-in CSS overrides used when you use the sliders and buttons in the [Aa] menu. Override CSS for kepub is more aggressive than the override CSS used for standard epub.

In the scenario you've raised the default override CSS for kepub text alignment is
Code:
div, p { text-align: %1 !important; }
so if you're wrapping your book's HTML <img> tags in a <div> or a <p> tag, then any text-align:center CSS styling is going to get overridden by whatever alignment button (left/justify) you've selected in the [Aa] menu.

You can combat this in one of 2 ways:
  1. If you're a user of the kobopatch system you can make the override CSS above less aggressive with a patch to the firmware. See patch Un-Force user text-align in div,p tags in KePubs
  2. If patching is not an acceptable option then you could try wrapping your book HTML <img> tags in any block HTML tag which is neither <div> nor <p>.
Personally I choose option 1. I have not tried option 2 (and it will probably make standards purists shudder ) but see no reason why it wouldn't work. Obviously you'd need to do it for every book.
jackie_w is offline   Reply With Quote