![]() |
#1 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 96
Karma: 511127
Join Date: May 2012
Device: Kindle Keyboard
|
kindlegen - center image using CSS only?
Wondering if kindlegen can center an image, using CSS only (no <center> in the HTML), for both Mobi and KF8 formats.
What I'm trying to do is create a single HTML page working for desktop and mobile browsers, and, via kindlegen, for Mobi and KF8, without any hacks. I have images which will be floated-right on larger displays, and centered on smaller ones, so I want to do the positioning in CSS only, and target different devices using Media Queries. For the centered image I have display: block; margin-left: auto; margin-right: auto; which is the normal way to do it, I believe. In the Kindle previewer (which I assume will work the same as kindlegen), this works fine for Kindle Fire/Kindle Touch devices, but for the standard Kindle it doesn't work, the image is just on the left margin. Any ideas? |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,400
Karma: 203720150
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Code:
p.image_container { text-indent: 0; text-align: center; } Code:
<p class="image_container"><img src="../Images/blahblah.jpg" /></p> |
![]() |
![]() |
![]() |
#3 |
frumious Bandersnatch
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,543
Karma: 19001583
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
Note that there's no CSS in MOBI at all. You can use CSS in your source file, but it will be converted to <center> or whatever by kindlegen.
|
![]() |
![]() |
![]() |
#4 | |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 96
Karma: 511127
Join Date: May 2012
Device: Kindle Keyboard
|
Quote:
Cheers. I'm not too worried about what the MOBI looks like internally, just whether I can really write source HTML which works in all cases. |
|
![]() |
![]() |
![]() |
#5 |
Groupie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 184
Karma: 2572
Join Date: Aug 2010
Device: Kindle
|
My images and captions are centered thus:
div.img { text-align:center; } div.text { text-align:center; font-style:italic; } I used to use small also, for the caption, but the results seemed uneven so I gave it up. |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to center an image vertically | GBAV | ePub | 31 | 08-01-2018 01:57 PM |
Kindlegen warning about css | sderrick | Kindle Formats | 1 | 04-17-2012 04:24 AM |
Center Image and Caption | SamL | ePub | 11 | 08-12-2011 09:27 AM |
image be in the center | yuxi_kelly | ePub | 2 | 03-19-2011 10:40 AM |
Center a cover image | Crusader | Sigil | 2 | 10-18-2009 08:51 AM |