11-29-2015, 11:34 AM | #1 |
Groupie
Posts: 171
Karma: 40000
Join Date: Oct 2013
Device: kindle
|
position:absolute and the disappearing html file
Hello.
I did some positioning in an AZW3. The code goes like this Code:
<div class="sgc1"> <p>ONE SHORT LINE</p> <p>another one</p> <p>3rd shortline</p> </div> <p class="sgc3"><img src="../images/00002.jpeg"/></p> To my surprise, the html file in question didn't show up in the kindle. It was simply skipped. It did show correctly, though, in the calibre previewer. I changed the sgc1 (and only that) to margin-top:10%, with no position declaration, and the file appeared again. Any idea what's going on? I tried this on two different devices, a paperwhite and an older one. Thanks Last edited by 1v4n0; 11-29-2015 at 11:47 AM. |
11-29-2015, 01:33 PM | #2 | |
Grand Sorcerer
Posts: 5,582
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
|
position: absolute isn't allowed in Kindle books. If you compile a book that uses it, you'll get the following warning:
Quote:
|
|
11-29-2015, 04:27 PM | #3 |
Groupie
Posts: 171
Karma: 40000
Join Date: Oct 2013
Device: kindle
|
ah, that's good to know. Any workarounds? Not that I use it a lot, but still-
|
11-29-2015, 06:10 PM | #4 |
Curmudgeon
Posts: 629
Karma: 1623086
Join Date: Jan 2012
Device: iPad, iPhone, Nook Simple Touch
|
There's not really a good alternative to position:absolute. It's a very basic, very critical part of the CSS specification. What you should avoid doing is using it to specify a page-relative absolute position, because that will not necessarily behave in the way you might expect, but this should be obvious to anybody who has ever done any significant amount of web development, making that warning from kindlegen pretty pointless.
FYI, my drop cap CSS on Kindle uses position:absolute, and I haven't seen any problems from doing so. AFAIK, neither has anyone else. I wouldn't use absolute positioning in KF7 code, but as long as you're only using it on the KF8 side, it should be safe to ignore the warning. |
11-30-2015, 04:12 AM | #5 |
Groupie
Posts: 171
Karma: 40000
Join Date: Oct 2013
Device: kindle
|
Well what surprised me is that the kindle skipped the html file altogether, but only if the first <p> had absolute positioning (or maybe it's because it can only tolerate one "absolutely-positioned" item per file?)
Also, the positioning for the image at the bottom does in fact work. As for KF7 vs KF8, I don't know what you're talking about This is an AZW3 I got from an EPUB I did, via calibre conversion. TY all. |
11-30-2015, 05:30 PM | #6 | |
Curmudgeon
Posts: 629
Karma: 1623086
Join Date: Jan 2012
Device: iPad, iPhone, Nook Simple Touch
|
Quote:
You can safely use absolute positioning on elements that are inside any enclosing element that is positioned in a non-fixed manner. Just don't use absolute positioning on elements whose ancestors are all position:fixed (the default). This is probably a bug in whatever version of WebKitGTK Amazon branched from. |
|
12-01-2015, 07:21 AM | #7 | |
mostly an observer
Posts: 1,515
Karma: 987654
Join Date: Dec 2012
Device: Kindle
|
Quote:
KF8 = more recent Kindles, Fires, and apps. I don't build the books any differently for the two formats. (Amazon is now moving into KFX; see the thread on that subject.) They look okay on both, though one can't control the size of images on KF7 devices. I'd keep Calibre out of it. I upload the epub to the KDP and let it convert there. |
|
12-01-2015, 07:37 AM | #8 |
Grand Sorcerer
Posts: 5,582
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
|
|
09-19-2017, 09:12 AM | #9 |
Connoisseur
Posts: 62
Karma: 10
Join Date: May 2011
Location: Japan
Device: Kindle3
|
Uuuurgh zombie thread . . . brains . . .
My workflow: Sigil 0.8.1 --> KP 2.942 --> .mobi --> PW2 I've been experimenting with position:absolute and :fixed so my title pages look like the book's title pages, with the publisher name fixed to the bottom of the page (or the title in the exact center) regardless of the font size and no need for fudging things with tables and endless fiddling with margins. . . . Seems to work fine, with the following caveats: 1. You MUST have a normal html/css thingy at the top, otherwise the whole page disappears. You gotta have something "above" it -- but not a space character. eg. <body> <div style="background-color:none; bottom:0; height:min-height; left:0; padding:0; position:fixed; width:100%;"><p>Simon & Specter</p> <p style="color:white;">.</p> </body> will display a page with a "hidden" full stop at the top and the publishers name at the bottom -- no matter what font size you select. 2. If you left- or right-align the absolute text, it seems to go to the absolute edge of the page -- past the margins the rest of the text will follow. I can't see a way around that except to set "left:70px" or whatever . . . ... You can do something similar with vertically centering some text too. I'm doing this for my own enjoyment, not publishing so they don't need to be compatible with . . . well, anything If anyone has a better method, I'd be keen to hear it. |
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Pocketbook 622 doesn't remember last position of a djvu file | marmistrz | PocketBook | 2 | 06-19-2015 12:37 PM |
Line spacing disappearing in .mobi file | John123 | Workshop | 6 | 12-15-2012 08:39 AM |
HTML input plugin stripping text within toc tags in child html file | nimblebooks | Conversion | 3 | 02-21-2012 03:24 PM |
Trying to upgrade my kindle 3 to 3.03, but the downloaded file keeps disappearing. | Bruce Wells | Amazon Kindle | 2 | 01-14-2011 12:23 AM |
ePub not supported < div > position: absolute | samsgates | ePub | 1 | 06-18-2010 11:22 AM |