05-26-2018, 03:51 AM | #1 |
Member
Posts: 12
Karma: 10
Join Date: May 2018
Device: Kindle Paperwhite
|
SVG and float CSS on Kindle
When I use float:left, it crushes my SVGs vertically in Kindle Previewer and the macOS Kindle app.
Here is my HTML: Code:
<p class="speechbubble chat-octopus"><span class="speechicon"><img src="../Images/file4.svg" alt="タコ"/></span>私たち</p> Code:
p.speechbubble img { width: 2em; height: 2em; margin: 0em; } span.speechicon { float: left; } And this is what it looks like if I remove float: left: When I use float:left with a JPG instead of an SVG, the JPG is fine (it is not vertically crushed like the SVG is). Is there a way to float SVGs without crushing them? Or do I need to convert them to PNG or JPG (I'm trying to avoid this because A) I scale the images at several points in the text and B) the transparency breaks sometimes when using PNG)? |
05-26-2018, 03:41 PM | #2 | |
Grand Sorcerer
Posts: 6,496
Karma: 84420419
Join Date: Nov 2011
Location: Tampa Bay, Florida
Device: Kindles
|
Quote:
That document also lists supported and unsupported SVG features. Possibly use of an unsupported feature is causing the problem. |
|
05-27-2018, 01:58 AM | #3 | |
Bookmaker & Cat Slave
Posts: 11,462
Karma: 158448243
Join Date: Apr 2010
Location: Phoenix, AZ
Device: K2, iPad, KFire, PPW, Voyage, NookColor. 2 Droid, Oasis, Boox Note2
|
Quote:
Look--we've done scads of books that are innovatively (cough) full of "speech bubbles." They are a nightmare to do, and they don't work very well, across devices--and, FWIW, they're godawful in the LITB. I have a client now that insists on redoing a book we did for her previously, b/c it doesn't/can't/won't work in the LITB--why on earth she thinks reshuffling the book will solve the problem, I don't know. I've repeatedly explained that it won't. The ONLY way to to what you want is one jpg-one bubble. Or, two bubbles to a jpeg, take your pick. Yes, it sucks, but that's the reality. Hitch |
|
05-27-2018, 10:08 AM | #4 | |
Wizard
Posts: 1,542
Karma: 6613969
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
I hope this can help you. Regards Rubén PS: Of course, instead of <text></text> you have to use <image></image> tags to include the picture you want. |
|
05-27-2018, 10:10 AM | #5 | |
Wizard
Posts: 1,542
Karma: 6613969
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
Maybe the method I use to include SVG images as DropCaps can be useful for you to include more than one svg image in a same page. Watch my previous post to see two SVG DropCaps in a same Kindle page. Regards Rubén |
|
05-27-2018, 07:24 PM | #6 | |
Bookmaker & Cat Slave
Posts: 11,462
Karma: 158448243
Join Date: Apr 2010
Location: Phoenix, AZ
Device: K2, iPad, KFire, PPW, Voyage, NookColor. 2 Droid, Oasis, Boox Note2
|
Quote:
Of course, I'll look at it--but it's highly unlikely we'll use it. I am still quite determined that I won't do anything that excludes a user from reading their book on a KF7. Oh, sure, we could probably work around it, but...{shrug}. It feels, at the moment, that it's more effort than the reward, but I will most surely look. ETA: Your svgs, Rubén, are being created on the fly. You are not using an existing SVG image. I'll investigate when I'm back at the office, but I suspect that our "coding" isn't massively different--but what we're talking about, is. Just like the OP, who is using existing SVG images. Do you see what I mean? Hitch Last edited by Hitch; 05-27-2018 at 07:34 PM. Reason: Added the ETA. |
|
05-28-2018, 06:43 AM | #7 |
Member
Posts: 12
Karma: 10
Join Date: May 2018
Device: Kindle Paperwhite
|
Rubén, thank you for the code example. I checked it out and it works in Kindle Previewer. It seems the difference is that I used a "drop caps" <span> (float: left) inside a <p>, whereas you use a "drop caps" <p> (float: left) inside a <div>.
So perhaps this is caused by the way Kindle handles <span> and <p>? I'll do some more testing to see if I can figure it out. |
05-28-2018, 08:07 AM | #8 | |
Wizard
Posts: 1,542
Karma: 6613969
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
|
|
05-28-2018, 01:17 PM | #9 | |
Bookmaker & Cat Slave
Posts: 11,462
Karma: 158448243
Join Date: Apr 2010
Location: Phoenix, AZ
Device: K2, iPad, KFire, PPW, Voyage, NookColor. 2 Droid, Oasis, Boox Note2
|
Quote:
Hitch |
|
05-28-2018, 04:23 PM | #10 | |
Wizard
Posts: 1,542
Karma: 6613969
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
I didn't have any issue to include more elaborated svg images; it works fine, watch for yourself: I was reading the Kindle Guidelines and the restriction I saw is that it can't have more than one <image> tag inside of a <svg> tag. But that is not a problem, just is matter of opening for each svg image one svg tag Enjoy your free days Rubén |
|
05-29-2018, 11:25 AM | #11 | |
Bookmaker & Cat Slave
Posts: 11,462
Karma: 158448243
Join Date: Apr 2010
Location: Phoenix, AZ
Device: K2, iPad, KFire, PPW, Voyage, NookColor. 2 Droid, Oasis, Boox Note2
|
Quote:
My guys tell me that the multiple-images-per "page" thing changed in Feb or March, so you're right, and I'm wrong--I'm apparently behind, a bit. They tell me that the real reason that we decided to not proceed with SVG was the (ironically) lack of zoomability. That's what drove our internal decision, and now that they're reminded me, I do remember this. We had a client with a boatload of vector graphics, and we looked into this for that book. At the time--beginning of the year--we still had that "page-break after each svg" problem to deal with, but I also now recall that they also weren't zoomable, and the client was having NONE of that, so...we put it back on the shelf for a while. Offered solely FWIW. I'll have my guys take some peeks at what you've done here, of course. :-) Hitch |
|
05-29-2018, 04:20 PM | #12 |
Wizard
Posts: 2,297
Karma: 12126329
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
Good to hear the "page-break after each SVG" was solved. I assume it was never mentioned in any sort of changelogs?
|
05-29-2018, 05:53 PM | #13 | |
Bookmaker & Cat Slave
Posts: 11,462
Karma: 158448243
Join Date: Apr 2010
Location: Phoenix, AZ
Device: K2, iPad, KFire, PPW, Voyage, NookColor. 2 Droid, Oasis, Boox Note2
|
Quote:
Hitch |
|
06-12-2018, 04:43 AM | #14 |
Member
Posts: 12
Karma: 10
Join Date: May 2018
Device: Kindle Paperwhite
|
Mostly working solution
Ok, after much more testing, I identified the problem.
Thanks to RbnJrg for the sample code which pointed me in the right direction. When you use an <img> tag for SVGs and set the height and width, this problem does not occur. However, if you leave the height and width blank and then attempt to set the height/width of the SVG to "~em" using CSS, then the Kindle app may squish the SVG to nothing. So there are two potential ways to fix this: 1) Set the height and width (which prevents the SVGs from automatically resizing when the user increases/decreases the text size) 2) Put the SVG in an <img> tag inside a <div> like this: Code:
<div class="speechbubble> <div class="speechicon"><img src="media/svg/mysvg.svg" alt="mysvg" /></div> <p class="speechtext">My text here.</p> </div> I now have this working (SVGs resize properly when the user increases/decreases the text size) on Paperwhite, iOS, and Windows and Mac apps. There are a few visual problems based on the fact that iOS vs. Windows/Mac vs. Paperwhite handle line-height and margins differently, but it's much better than before. Many thanks! |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
EPUB to MOBI (AZW3). Black SVG images with CSS styles | uka | Conversion | 6 | 03-04-2018 09:50 PM |
Can't add cover in Calibre -- get "svg-error" (the property 'svg' should be declared) | Just some guy | Editor | 7 | 04-11-2017 09:54 PM |
Using float in ADR v1 and v2 | bobcdy | ePub | 5 | 01-31-2015 02:36 AM |
The operator >> is undefined for the argument type(s) float, float | twobob | Kindle Developer's Corner | 10 | 09-05-2012 12:50 PM |
Kindle and SVG? | Tom Wood | News | 1 | 09-03-2010 08:06 PM |