Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > Kindle Formats

Notices

Reply
 
Thread Tools Search this Thread
Old 09-16-2012, 01:19 PM   #1
mjwilson
Connoisseur
mjwilson ought to be getting tired of karma fortunes by now.mjwilson ought to be getting tired of karma fortunes by now.mjwilson ought to be getting tired of karma fortunes by now.mjwilson ought to be getting tired of karma fortunes by now.mjwilson ought to be getting tired of karma fortunes by now.mjwilson ought to be getting tired of karma fortunes by now.mjwilson ought to be getting tired of karma fortunes by now.mjwilson ought to be getting tired of karma fortunes by now.mjwilson ought to be getting tired of karma fortunes by now.mjwilson ought to be getting tired of karma fortunes by now.mjwilson ought to be getting tired of karma fortunes by now.
 
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?
mjwilson is offline   Reply With Quote
Old 09-16-2012, 06:26 PM   #2
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,546
Karma: 193191846
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>
DiapDealer is offline   Reply With Quote
Advert
Old 09-17-2012, 04:06 AM   #3
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,515
Karma: 18512745
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.
Jellby is offline   Reply With Quote
Old 09-17-2012, 12:32 PM   #4
mjwilson
Connoisseur
mjwilson ought to be getting tired of karma fortunes by now.mjwilson ought to be getting tired of karma fortunes by now.mjwilson ought to be getting tired of karma fortunes by now.mjwilson ought to be getting tired of karma fortunes by now.mjwilson ought to be getting tired of karma fortunes by now.mjwilson ought to be getting tired of karma fortunes by now.mjwilson ought to be getting tired of karma fortunes by now.mjwilson ought to be getting tired of karma fortunes by now.mjwilson ought to be getting tired of karma fortunes by now.mjwilson ought to be getting tired of karma fortunes by now.mjwilson ought to be getting tired of karma fortunes by now.
 
Posts: 96
Karma: 511127
Join Date: May 2012
Device: Kindle Keyboard
Quote:
Originally Posted by DiapDealer View Post
Code:
p.image_container {
    text-indent: 0;
    text-align: center;
    }
Code:
<p class="image_container"><img src="../Images/blahblah.jpg" /></p>
Thanks!

Quote:
Originally Posted by Jellby View Post
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.
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.
mjwilson is offline   Reply With Quote
Old 09-18-2012, 06:02 AM   #5
Oldpilot
Groupie
Oldpilot plays well with othersOldpilot plays well with othersOldpilot plays well with othersOldpilot plays well with othersOldpilot plays well with othersOldpilot plays well with othersOldpilot plays well with othersOldpilot plays well with othersOldpilot plays well with othersOldpilot plays well with othersOldpilot plays well with others
 
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.
Oldpilot is offline   Reply With Quote
Advert
Reply


Forum Jump

Similar Threads
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


All times are GMT -4. The time now is 06:35 PM.


MobileRead.com is a privately owned, operated and funded community.