![]() |
#1 |
I mess around with Epubs
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 82
Karma: 1566
Join Date: Mar 2011
Location: Cambridge, MA
Device: mac, ipad, nook, kindle
|
Centering Images using object styles
So I am using images for my chapter headings for my book. To make sure they will display alright across different platforms, I've made the width 500px. Because of this, the image does not take up the whole width on some platforms like the iPad.
I need to center all of these images. What I was doing before was going in to all the XHTML files and putting in <div align="center"> tags. This displayed the images exactly how I want them. I noticed that once I tried to validate my epub, there were errors in the use of my align tags. Upon further reading, it looks like I need to apply object styles to my images in inDesign, that does this alignment. I am able to apply the object style, but when I look at my CSS file, it recognizes the style, but has no attributes to it (I read this is a common problem.) so in my CSS file, it looks like this: div.center-image { } And in the XHTML file, is applies the style to the images correctly. Can anyone recommend what I should put in for code for this CSS, I've tried a few different things, but I haven't really used object styles until now. Any help would be greatly appreciated. Thanks |
![]() |
![]() |
![]() |
#2 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 351
Karma: 70000
Join Date: Jul 2010
Location: Australia
Device: ADE, iPad
|
Code:
div.center-image { margin-top: 0%; text-indent: 0%; text-align: center; margin-bottom:0%; } img { max-width: 100% } |
![]() |
![]() |
Advert | |
|
![]() |
#3 | |||
I mess around with Epubs
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 82
Karma: 1566
Join Date: Mar 2011
Location: Cambridge, MA
Device: mac, ipad, nook, kindle
|
Hmmmm, still not working. It is still aligning left.
This is what my code looks like. CSS: Quote:
Quote:
Quote:
|
|||
![]() |
![]() |
![]() |
#4 |
frumious Bandersnatch
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,543
Karma: 19001583
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
If you define the style for div.center-image, it's pointless to use <span class="center-image">, or to add a "center-image" class to anything other than a <div>. Moreover, a <span> does not use a text-align property. And you can't have block-level elements (like <div>) inside a <p>.
Try this: Code:
<div align="center-image"> <img src="images/Stern_title_fmt.jpeg" alt="Stern_title.jpg" /> </div> Last edited by Jellby; 03-29-2011 at 05:11 AM. |
![]() |
![]() |
![]() |
#5 | |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,884
Karma: 59840450
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
![]() TTS will have trouble pronouncing 'jpg' (Jay' Peg). ![]() I prefer to use: Image or Picture or Map as a suffix rather than a file extension (that some users may not even know is a image file type) |
|
![]() |
![]() |
Advert | |
|
![]() |
#6 | |
I mess around with Epubs
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 82
Karma: 1566
Join Date: Mar 2011
Location: Cambridge, MA
Device: mac, ipad, nook, kindle
|
Quote:
ERROR: Stern Folder.epub/OEBPS/Stern.xhtml(14): attribute "align" not allowed here; expected attribute "class", "dir", "id", "style", "title" or "xml:lang" So thats why I am trying to find another way to center the image. Thanks for the help so far everyone! |
|
![]() |
![]() |
![]() |
#7 |
frumious Bandersnatch
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,543
Karma: 19001583
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
|
![]() |
![]() |
![]() |
#8 | |
I mess around with Epubs
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 82
Karma: 1566
Join Date: Mar 2011
Location: Cambridge, MA
Device: mac, ipad, nook, kindle
|
Ok I got it to work. I needed to use a <p> class instead of a div. I used:
Quote:
|
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Centering blockquotes | ghostyjack | ePub | 6 | 07-17-2014 06:07 AM |
Centering PDF | nguirado | Amazon Kindle | 5 | 10-04-2010 08:45 PM |
How to center/fit page width SVG images with <OBJECT> | amoroso | ePub | 0 | 07-31-2010 11:48 AM |
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 |