Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Conversion

Notices

Reply
 
Thread Tools Search this Thread
Old 09-14-2014, 07:09 PM   #1
perkin5
Member
perkin5 began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Sep 2014
Device: Kindle
Centering images

I want to center a 70px wide image inside a span tag which is the default 100% width. I gave the span a class and styled it as
Code:
text-align:center
and that looks fine when viewed as an epub. However when I convert it to a mobi format in Calibre and then view it in the 'Kindle for PC' reader, it is offset to the right.

Can anyone suggest what is going on?
perkin5 is offline   Reply With Quote
Old 09-14-2014, 07:23 PM   #2
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 20,587
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by perkin5 View Post
I want to center a 70px wide image inside a span tag which is the default 100% width. I gave the span a class and styled it as
Code:
text-align:center
and that looks fine when viewed as an epub. However when I convert it to a mobi format in Calibre and then view it in the 'Kindle for PC' reader, it is offset to the right.

Can anyone suggest what is going on?
@perkin5 - mayhap K4PC is misleading you, have a read of this thread ==>> Help! Formatting Internal Images is making me crazy!

BR
BetterRed is online now   Reply With Quote
Advert
Old 09-14-2014, 10:29 PM   #3
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,867
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Convert it to AZW3, not MOBI. MOBI is an obsolete format. If you do want it centered in MOBI you will need to put it in a <div> tag, not a <span> tag.
kovidgoyal is online now   Reply With Quote
Old 09-15-2014, 11:05 AM   #4
dwig
Wizard
dwig ought to be getting tired of karma fortunes by now.dwig ought to be getting tired of karma fortunes by now.dwig ought to be getting tired of karma fortunes by now.dwig ought to be getting tired of karma fortunes by now.dwig ought to be getting tired of karma fortunes by now.dwig ought to be getting tired of karma fortunes by now.dwig ought to be getting tired of karma fortunes by now.dwig ought to be getting tired of karma fortunes by now.dwig ought to be getting tired of karma fortunes by now.dwig ought to be getting tired of karma fortunes by now.dwig ought to be getting tired of karma fortunes by now.
 
dwig's Avatar
 
Posts: 1,613
Karma: 6718479
Join Date: Dec 2004
Location: Paradise (Key West, FL)
Device: Current:Surface Go & Kindle 3 - Retired: DellV8p, Clie UX50, ...
Quote:
Originally Posted by perkin5 View Post
I want to center a 70px wide image inside a span tag ...
If you must use a <SPAN> do as Kovid instructs and use AZW3 instead of the old MOBI format.

If you must use the old MOBI then you need to place the image in <P> or <DIV> instead of a <SPAN>. If you do, it will center. The old MOBI is a good format, but is based on an earlier and simpler version of HTML and doesn't support many of the newfangled fancy HTML/CSS tricks.
dwig is offline   Reply With Quote
Old 09-16-2014, 12:22 PM   #5
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 74,037
Karma: 129333114
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
A <span> tag is bad form even in an ePub or KF8. It may work in whatever software you are using to view it now, but eventually, you'll find some software that it won't work with. Go with the <p> or <div> as has been mentioned as that's proper form.
JSWolf is offline   Reply With Quote
Advert
Old 09-18-2014, 12:05 AM   #6
Wendy Wolfe
Member
Wendy Wolfe began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Sep 2014
Device: Kindle DX, Kindle Fire HDX 7", iOS (iPhone and iPad)
(Warning: I'm an ebook newbie)

I have centered images using the following. Is it bad ebook form?

CSS snippit:
.ImgCenter
{
text-align: center;
}

HTML:
<figure class="ImgCenter" >
<img alt="IMG" src="../your_image_file.jpg"/>
<br />
<figcaption><b>Fig I.II:</b> Description </figcaption>
</figure>

(I've also tweeked the margin attributes to attach the caption to the image, but that's a bit off-topic.)
Wendy Wolfe is offline   Reply With Quote
Old 09-19-2014, 09:55 AM   #7
perkin5
Member
perkin5 began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Sep 2014
Device: Kindle
Quote:
Originally Posted by kovidgoyal View Post
Convert it to AZW3, not MOBI. MOBI is an obsolete format. If you do want it centered in MOBI you will need to put it in a <div> tag, not a <span> tag.
Many thanks for that good advice! I'll do as you say.
perkin5 is offline   Reply With Quote
Old 09-19-2014, 09:56 AM   #8
perkin5
Member
perkin5 began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Sep 2014
Device: Kindle
Quote:
Originally Posted by JSWolf View Post
A <span> tag is bad form even in an ePub or KF8. It may work in whatever software you are using to view it now, but eventually, you'll find some software that it won't work with. Go with the <p> or <div> as has been mentioned as that's proper form.
OK got it - thanks!
perkin5 is offline   Reply With Quote
Old 09-19-2014, 10:40 AM   #9
Wendy Wolfe
Member
Wendy Wolfe began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Sep 2014
Device: Kindle DX, Kindle Fire HDX 7", iOS (iPhone and iPad)
(Folks can ignore my post... I've played around with centering & now understand the advantages of the <div>.)
Wendy Wolfe is offline   Reply With Quote
Reply

Tags
calibre, html, kindle


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Centering blockquotes ghostyjack ePub 6 07-17-2014 06:07 AM
Nook not centering anything. why? kateharp ePub 0 05-11-2011 10:53 PM
Centering Images using object styles SamL ePub 7 04-05-2011 01:28 PM
How to do centering sjohnson717 Calibre 15 02-28-2010 09:20 AM
centering images with css override? Amalthia Calibre 2 03-30-2009 01:53 PM


All times are GMT -4. The time now is 09:28 PM.


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