Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 05-12-2011, 01:35 PM   #1
marcelo2605
Member
marcelo2605 began at the beginning.
 
Posts: 19
Karma: 10
Join Date: Apr 2011
Device: iPad
Center a div

Is possible center a div without using text-align?

I have a page with one big image and a small text, like a caption, and I would center both, but the text still align left.

In websites is commom use margin-left/right:auto and div align: center. But this look like doesn't work in epub.
marcelo2605 is offline   Reply With Quote
Old 05-12-2011, 06:43 PM   #2
Faster
Connoisseur
Faster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of lightFaster is a glorious beacon of light
 
Posts: 60
Karma: 12096
Join Date: Sep 2010
Location: Tasmania
Device: Sony PRS 650
Misunderstood. Reply removed.

Last edited by Faster; 05-14-2011 at 03:56 PM.
Faster is offline   Reply With Quote
 
Enthusiast
Old 05-13-2011, 04:32 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: 5,974
Karma: 4346919
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by marcelo2605 View Post
I have a page with one big image and a small text, like a caption, and I would center both, but the text still align left.
What do you mean the text is "centered, but still aligned left"? I'm guessing you want a left-aligned text block, but that does not take the full page width, having equal right and left margins. something like this:

Code:
---------------------------
|         XXXXX           |
|                         |
|     Fig1. caption       |
|     text.               |
|                         |
| Normal  text  paragraph |
| with full justification |
| etc.                    |
---------------------------
In that case, you have to either set an explicit width for the text block and "auto" margins (which do not work in some readers), or set the margins explicitly, i.e.:

Code:
<div class="illustration">
<img src="image.jpg" alt="" />
<p class="caption">Fig. 1: Caption text.</p>
</div>

div.illustration {
  text-align: center; /* this centers the image */
}
p.caption {
  text-align: left; /* this keeps the caption left-aligned */
  /* to center the caption block, use */
  /* either these two lines: */
  width: 60%;
  margin: 0 auto;
  /* or just this one: */
  margin: 0 20%;
}
Jellby is offline   Reply With Quote
Old 05-13-2011, 06:57 AM   #4
marcelo2605
Member
marcelo2605 began at the beginning.
 
Posts: 19
Karma: 10
Join Date: Apr 2011
Device: iPad
Thanks Jellby. I think it will help.
marcelo2605 is offline   Reply With Quote
Old 05-13-2011, 07:39 AM   #5
marcelo2605
Member
marcelo2605 began at the beginning.
 
Posts: 19
Karma: 10
Join Date: Apr 2011
Device: iPad
The second way (margin: 0 20%

works better in ADE and Calibre.
marcelo2605 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mobipocket conversion: div bgcolor and border kentmatt Conversion 3 01-23-2011 12:46 AM
Can you delete div with align=center mufc Recipes 4 12-10-2010 06:23 PM
Questions about <p> and <div> and paragraph spacing droople Sigil 7 08-14-2010 12:03 PM
Remove spacing between paragraphs - what about div tags ? NASCARaddicted Calibre 5 11-07-2009 05:47 AM
Exclude <div>s from processing in HTML2LRF MTBSJC Calibre 1 02-13-2009 03:26 AM


All times are GMT -4. The time now is 05:43 PM.


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