10-07-2014, 05:03 AM | #1 |
Wizard
Posts: 3,413
Karma: 13369310
Join Date: May 2008
Location: Launceston, Tasmania
Device: Sony PRS T3, Kobo Glo, Kindle Touch, iPad, Samsung SB 2 tablet
|
Centering images in iPad mini/iBooks/iOS8
I rarely use iBooks except for checking ebooks I've designed, so this problem may be old news to some people.
The latest ebook I uploaded uses the following XHTML and CSS to centre images: <div class="centre"> <img src="images/valid.png" width="25%" alt="valid html, css, and epub" /> </div> .centre { text-indent: 0; text-align: center; } It has worked perfectly well to centre images on an iPad2 in the past, and worked perfectly well tonight on my Sony PRS T3, a Kobo Touch, iPad mini with Marvin, Nexus 7 with Mantano, and upgraded Kindle Keyboard. But on an iPad mini the images are flush with the left margin - not centred at all. Has anyone else seen this problem? Is it a problem with an iPad mini? Or iOS8 and the latest version of iBooks? I can't believe it's because of my markup and CSS since they worked in the past and work on other ebook readers. Perhaps more importantly: is there a way to centre images with this combination (iPad mini, latest iBooks, and iOS8) that will also work on other ebook readers? I should mention perhaps that an image which is floated right and has text wrapped around it still works on the iPad mini. And the CSS still centres text material on an iPad mini. If you need to check the markup and the CSS the book is Right at Last and Other Tales by Elizabeth Gaskell. Last edited by AlexBell; 10-07-2014 at 05:06 AM. Reason: Added ps |
10-07-2014, 07:58 AM | #2 |
Wizard
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
mistake
Last edited by roger64; 10-07-2014 at 07:59 AM. Reason: mistake |
Advert | |
|
10-07-2014, 09:15 AM | #3 |
Addict
Posts: 398
Karma: 96448
Join Date: Dec 2013
Device: iPad
|
Google search for centering a div
|
10-07-2014, 10:10 AM | #4 |
Wizard
Posts: 1,539
Karma: 6613969
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Images are not the same as text. It's possible that ereaders will display images centered using the text-align property but it’s not a good idea. Instead, you should specify that the image is a block element. Then you can center it as you would a block:
Code:
img.centered { display: block; margin-left: auto; margin-right: auto; } Code:
<div class="centre"> <img class="centered" alt="valid html, css, and epub" src="../Images/valid.png" width="25%" /> </div> Regards Rubén |
10-07-2014, 11:03 AM | #5 |
Zealot
Posts: 103
Karma: 57138
Join Date: May 2010
Device: Sony 505, iPad 1 & 3, Galaxy Note 8.1
|
I think this is a bug in the new iOS 8.0.2 release of iBooks. I'm having other cover related issues with iBooks now and nothing, not even the above css seems to work. At this point I'm just waiting on 8.1 to hit and see if that fixes it.
<rant> This is one problem with how Apple decided to make iBooks a part of iOS, you now have to wait on an update of the whole system just to get bugs fixed in one app. And you can't remove apps you don't need. Apple is becoming as bad as the phone providers when it comes to bloatware. </rant> |
Advert | |
|
10-07-2014, 11:15 AM | #6 | |
Wizard
Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
|
Quote:
In iBooks it could work. Last edited by Toxaris; 10-07-2014 at 11:27 AM. |
|
10-07-2014, 11:24 AM | #7 |
frumious Bandersnatch
Posts: 7,515
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
They should be the same if they are inline elements. And note that the text-align property is applied to the container, not to the <img>. This should work in a compliant renderer (in the absence of other rules).
|
10-07-2014, 05:41 PM | #8 |
Wizard
Posts: 1,539
Karma: 6613969
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Yes, of course. For that reason I added the class "centered" to the image tag. The div tag retains the class "center" (Alex's original) so the epub will continue working on the ereaders where already works and by adding the class "centered" to the <img> tag now it should also work in iBooks. At least, that is the idea
|
10-07-2014, 05:43 PM | #9 |
Wizard
Posts: 1,539
Karma: 6613969
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Yes, you are right. For that reason I retained the Alex's class "center". Read my previous post.
|
10-07-2014, 06:00 PM | #10 |
Wizard
Posts: 3,413
Karma: 13369310
Join Date: May 2008
Location: Launceston, Tasmania
Device: Sony PRS T3, Kobo Glo, Kindle Touch, iPad, Samsung SB 2 tablet
|
Thanks for all the suggestions.
Is there anyone around who uses an iPad and iBooks and can tell me whether they've had the same or similar problems? The exact same markup and stylesheet that I've quoted worked on an iPad some time ago, and I'd really like to know what has made the difference. |
10-19-2014, 08:20 PM | #11 |
Wizard
Posts: 3,413
Karma: 13369310
Join Date: May 2008
Location: Launceston, Tasmania
Device: Sony PRS T3, Kobo Glo, Kindle Touch, iPad, Samsung SB 2 tablet
|
This is late, I know, but I realised that the problem might be that the markup in my first post does not set the img to display: inline.
I added this to the CSS file div.centre img { display: inline; } and the images are centered in iBooks as well as all the other readers. I'm afraid I don't know enough about CSS to know whether iBooks is being too strict in requiring that the image display: inline, or whether ADE and Marvin is being too lax in not requiring this. Any comments? |
10-20-2014, 02:40 AM | #12 | |
Developer of EPUBReader
Posts: 271
Karma: 1922
Join Date: Oct 2009
Device: none
|
Quote:
|
|
10-20-2014, 06:07 AM | #13 | |
Wizard
Posts: 3,413
Karma: 13369310
Join Date: May 2008
Location: Launceston, Tasmania
Device: Sony PRS T3, Kobo Glo, Kindle Touch, iPad, Samsung SB 2 tablet
|
Quote:
I'm not too surprised: I can remember the days when one had to scatter unnecessary <span></span>s around to get ePubs to work properly in iBooks. |
|
10-20-2014, 05:28 PM | #14 |
Zealot
Posts: 103
Karma: 57138
Join Date: May 2010
Device: Sony 505, iPad 1 & 3, Galaxy Note 8.1
|
Just updated my my iPad mini to iOS 8.1 and it fixed the issues I was having with iBooks. Might check yours again.
|
10-20-2014, 06:09 PM | #15 |
Wizard
Posts: 3,413
Karma: 13369310
Join Date: May 2008
Location: Launceston, Tasmania
Device: Sony PRS T3, Kobo Glo, Kindle Touch, iPad, Samsung SB 2 tablet
|
Thanks, I'll give that a try. At least my solution won't do any harm even if it is unnecessary. And perhaps it will prevent problems with the next iOS update.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
No superscript on iPad since iOS8 | buecherhans | Apple Devices | 7 | 10-27-2014 10:49 AM |
Calibre cannot detect ipad air with ios8 | mapline | Marvin | 9 | 09-26-2014 11:37 AM |
Centering images | perkin5 | Conversion | 8 | 09-19-2014 10:40 AM |
Irregular images on an iPad/iBooks | AlexBell | ePub | 12 | 04-02-2013 08:35 AM |
Centering SVG graphics in iBooks? | FunkeXMix | ePub | 8 | 01-04-2013 09:21 PM |