07-13-2010, 08:36 AM | #1 |
Enthusiast
Posts: 28
Karma: 10
Join Date: May 2010
Location: Stockholm
Device: iPhone, iPad, Nook, Bookeen, Sony Reader
|
margin: 0 auto;
Hi all! I'm trying to set a
Code:
margin: 0 auto; Can't seem to make it work, I've tried it in iBooks and ADE. |
07-13-2010, 09:19 AM | #2 |
frumious Bandersnatch
Posts: 7,536
Karma: 19000001
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
You need two things at least:
1. A fixed (or maximum) width for the block, otherwise the block takes the full page width and "auto" means "0", unless it is a table. 2. Support from the reader. As far as I know, ADE does not support "auto" (I don't know about iBooks), so you'll most likely not see the effect. |
Advert | |
|
07-13-2010, 05:31 PM | #3 |
Groupie
Posts: 161
Karma: 608
Join Date: Aug 2008
Location: Plano, TX
Device: Sony PRS-505 + B&N Nook + Motion LE1700 + Motorola Xoom Wifi
|
I've been beating my head against the wall on this too.
Any suggestions on how to center a block of left-justified text on todays crop of ereaders? Troy |
07-14-2010, 04:02 AM | #4 | |
Enthusiast
Posts: 28
Karma: 10
Join Date: May 2010
Location: Stockholm
Device: iPhone, iPad, Nook, Bookeen, Sony Reader
|
Quote:
2. Perhaps we can find a work around that readers do support? |
|
07-14-2010, 05:14 AM | #5 | ||
frumious Bandersnatch
Posts: 7,536
Karma: 19000001
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
Quote:
"Reading Systems may set the value of any margin property whose specified value is auto to 0." Quote:
Or maybe setting "display: inline" and wrapping it into a <div> with "text-align: center". For a table, which has a width that by default adapts to its contents, I'm not sure what would work... You can always write polite emails (but many) to Adobe and Apple |
||
Advert | |
|
07-15-2010, 02:16 AM | #6 |
Member
Posts: 19
Karma: 10
Join Date: Jul 2010
Device: iPad, Sony Reader, Kindle 2
|
margin: 0 auto;
display: table; This would work in iBooks. It would not work in ADE or Sony Reader. |
07-15-2010, 04:16 PM | #7 |
Resident Curmudgeon
Posts: 76,436
Karma: 136564696
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
|
07-15-2010, 07:11 PM | #8 |
Groupie
Posts: 161
Karma: 608
Join Date: Aug 2008
Location: Plano, TX
Device: Sony PRS-505 + B&N Nook + Motion LE1700 + Motorola Xoom Wifi
|
|
07-16-2010, 04:41 AM | #9 |
frumious Bandersnatch
Posts: 7,536
Karma: 19000001
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
For poetry, while "centering the block" would be the best way, I set it with a larger left margin (2em, when the normal indent is 1em).
If at some point you get a reader that supports "auto", you can just change the margins to "auto". Or, you can set "auto" margins right now, and 2em padding. A reader that does support "auto" shows it properly centered, while a reader that doesn't will show the "second best" option |
07-16-2010, 12:11 PM | #10 | |
Resident Curmudgeon
Posts: 76,436
Karma: 136564696
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
|
|
07-16-2010, 12:31 PM | #11 | |
frumious Bandersnatch
Posts: 7,536
Karma: 19000001
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
Quote:
If fact, ideally I'd like to define something more complex that depends on the font size, page size, orientation, etc. and has some maximum and minimum values (for instance: 20% of page width, but not less than 2em, and not more than 1.5cm). This is currently not possible, it might be with CSS3, though; as a compromise I prefer to use ems in this case, but I only gave it as an example. By the way, using px is just as wrong, as it is dependent on the device resolution, and sometimes it's not even defined (what is a pixel when converting to PDF with prince?). |
|
07-16-2010, 12:41 PM | #12 |
Resident Curmudgeon
Posts: 76,436
Karma: 136564696
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
This is not about PDF. This is about ePub. So converting ePub to PDF is irrelevant.
Personally, I'd just find it really annoying to have the margins change with the text size. I would either have to fix it myself or just not read the book and also maybe put you in the thread about poorly made eBooks. |
07-16-2010, 01:39 PM | #13 | ||
frumious Bandersnatch
Posts: 7,536
Karma: 19000001
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
Quote:
Quote:
|
||
07-16-2010, 04:34 PM | #14 | |
Groupie
Posts: 165
Karma: 339490
Join Date: May 2010
Device: nook, BlackBerry
|
Quote:
Problem: inline-blocks can't wrap pages (because they are treated as a single element). Solution: create a separate block for each verse - hopefully your verses aren't too long. New Problem: Using the above solution, each verse will now be centered relative to its own line lengths, not relative to the entire poem. Solution: create a custom negative margin for each verse (except the widest, of course) to align the left edges of all the verses. If you specify this margin in "em" instead of "%" it will stay fairly close to aligned at different font sizes/different screen widths. It's not perfect, but it's the best I can come up with given the current limitations. If you want some sample code, I can post it later when I get home. |
|
07-16-2010, 05:06 PM | #15 | |
Groupie
Posts: 161
Karma: 608
Join Date: Aug 2008
Location: Plano, TX
Device: Sony PRS-505 + B&N Nook + Motion LE1700 + Motorola Xoom Wifi
|
Quote:
Have you tried that on any ADE based ereader? I didn't think inline-block was supported in epubs. And how did you center the outside block without auto margins? Troy |
|
Tags |
css, epub |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Margin question | Switch | Calibre | 11 | 05-13-2010 04:32 PM |
How to shrink margin? | tomsem | Kindle Developer's Corner | 2 | 12-11-2009 11:20 PM |
calibre ignore margin-top and margin-bottom | bender | Calibre | 2 | 12-11-2009 07:58 AM |
Margin sizes... | M0zza | Calibre | 2 | 09-22-2008 05:02 AM |
Right Margin Control | TedPark | Sony Reader Dev Corner | 4 | 07-02-2008 08:41 AM |