![]() |
#1 |
Junior Member
![]() Posts: 9
Karma: 10
Join Date: Dec 2011
Device: none
|
Centering objects in Adobe Digital Editions?
Not really sure where to post this.
Basically, i use Sigil to create EPUBs. However, I've noticed that the usual centering doesn't work in ADE. And by "usual" I mean by the way it's usually done in web development---to center something, style it with margin-left:auto and margin-right:auto. Assuming the width has been explicitly defined, this technique centers DIVs, Ps, IMGs, TABLEs, ... basically anything. It also works in every major browser, even the buggy IE 6 if I recall correctly! However, this technique apparently does not work in ADE. I'm running the latest version for windows, which is presumably 1.7.2. I've noticed that to center IMGs, some vendors wrap it in a paragraph P that's centered vertically: Code:
<p style="text-align:center;"><img /></p> So are there any workarounds? How do you center objects in ADE? |
![]() |
![]() |
![]() |
#2 |
frumious Bandersnatch
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,542
Karma: 19001583
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
With "text-align: center".
Unfortunately, ADE is following the specification. The spec says that reader agents may treat "auto" values in margin as if they were zero, i.e., they are not required to support "auto". We would all like ADE to do otherwise, but Adobe chose differently ![]() This is a corollary of Murphy's law: if something can be "not supported", some reader will "not support" it. |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Junior Member
![]() Posts: 9
Karma: 10
Join Date: Dec 2011
Device: none
|
Darn it, so you're saying that I have to apply "text-align: center" to everything that I want centered?
|
![]() |
![]() |
![]() |
#4 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
|
Yes. That is the only way.
|
![]() |
![]() |
![]() |
#5 |
Junior Member
![]() Posts: 9
Karma: 10
Join Date: Dec 2011
Device: none
|
I just tried that on IMGs and TABLEs and it does not work. To be clear, in the CSS, I added:
Code:
img { text-align: center; } table { text-align: center; } |
![]() |
![]() |
Advert | |
|
![]() |
#6 | |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,876
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:
Code:
hr { display: block; margin-left: 25%;width:50%; } |
|
![]() |
![]() |
![]() |
#7 |
Junior Member
![]() Posts: 9
Karma: 10
Join Date: Dec 2011
Device: none
|
Oh right, why didn't I think of that? :-)
It's a good idea on images since using pixels or EMs for image widths breaks ADE---when the image is wider than the screen. However, it doesn't seem to be working for tables. I tried setting width:30% to a table that's a child of a DIV that takes up the whole screen. The table is not 30% of that DIV. No other widths in the table are set |
![]() |
![]() |
![]() |
#8 |
Junior Member
![]() Posts: 9
Karma: 10
Join Date: Dec 2011
Device: none
|
<beginRant> Why can't ADE use a modern renderer? </endRant>
|
![]() |
![]() |
![]() |
#9 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
|
It is not about a modern or non-modern renderer. It is about following the specifications.
However, a table can be centered, as well as an image. Setting the text-align: center on the img tag itself will not help. You will have to put the image in a <p> or <div> tag with the text-align: center setting. The same principle also works for the table, but you need <div> then, the <p> will not work. I think I remember that is correct for tables, but I cannot test now. |
![]() |
![]() |
![]() |
#10 |
frumious Bandersnatch
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,542
Karma: 19001583
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
For images, and for anything else, you have to use "text-align: center" in the containing element.
But tables are different, as they have no native width, but adapt their width to their contents... I believe tables do not obey text-align (but the text inside the table cells does). The way to center a table would be with "margin: 0 auto;", but since "auto" is not supported, the only way is assigning a fixed relative width to a table, and then dividing the rest between right and left margins: table { /* 60%+20%+20% = 100% */ width: 60%; margin-left: 20%; margin-right: 20%; } Or, my preferred solution, just use "auto" and bear with the rendering being sub-optimal in ADE, at least it will be nicely coded and work properly in any reader with better support (present or future). By the way, when you want a centered image, you'll often want something like: <div class="illustration"> <img src="..." alt="" /> </div> div.illustration { margin: 1em 0; text-align: center; } div.illustration img { max-width: 100%; max-height: 100%; } So having to use "text-align: center" is no real cluttering. Last edited by Jellby; 12-16-2011 at 04:16 AM. |
![]() |
![]() |
![]() |
#11 |
Junior Member
![]() Posts: 9
Karma: 10
Join Date: Dec 2011
Device: none
|
@jellby -- as stated above, setting a table width as a percent gives unexpected results.
@toxaris-- i'm coming from a web developer background. Are you sure ADE is modern? It doesn't support :before or :after for crying out loud. In many ways, it's just as bad as IE6. Just tried two tables one wrapped in a DIV and the other in a P. Neither centered horizontally. Will double-check my code and report back if I get it to work. But for now I'm giving up. I think I can live with tables with a fixed left margin or correctly centered everywhere else. However, for images, setting a width as a percent and margin-left also as a percent is an excellent idea I'll be using. |
![]() |
![]() |
![]() |
#12 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,336
Karma: 203719142
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
|
|
![]() |
![]() |
![]() |
#13 |
Junior Member
![]() Posts: 9
Karma: 10
Join Date: Dec 2011
Device: none
|
@toxaris --- iBooks uses webkit as a rendering engine. It gives really good and predictable results. Other ePub readers also use browser as their underlying browsing engines.
Speaking of specs, according to the official EPUB specs, version 2 in many cases just picks up the official CSS2 specs! In fact, for margin-left: auto applied to DIVs and tables, the official specs say that it should behave just like a browser. Here read it for yourself: http://idpf.org/epub/20/spec/OPS_2.0.1_draft.htm That document tells us that for margin-left the EPUB specs follow CCS2 section 8.3. Those specs tell us that for DIVs and tables (block-level, non-replaced elements in normal flow), margin-left:auto, and margin-right:auto should center the object horizontally: http://www.w3.org/TR/CSS2/visudet.ht...hs_and_margins So there you go. ADE sucks. The only reason I'm using it is because of the DRM. |
![]() |
![]() |
![]() |
#14 | |||
frumious Bandersnatch
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,542
Karma: 19001583
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
Quote:
Quote:
[1] Reading Systems may set the value of any margin property whose specified value is auto to 0. Quote:
If you want to complain, start complaining about the lack of support for small-caps. Those are in the spec and they have no "alternative display". Or about Unicode bidi (or right-to-left writing). Or about their treatment of oeb-page-head, which is worse than what a pure browser would do. Last edited by Jellby; 12-16-2011 at 12:36 PM. |
|||
![]() |
![]() |
![]() |
#15 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
|
Compared to iBooks, ADE is a bliss and very predictable. With iBooks each version will render the results different and something else is broken.
|
![]() |
![]() |
![]() |
Tags |
ade, adobe digital editions, centering |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Downloading Adobe Ebook pdf files crashes Adobe Digital Editions .... | Zevs | Sony Reader | 2 | 09-17-2010 12:25 PM |
New verions of Adobe Digital Editions - Digital Editions 1.7.2 | kennyc | ePub | 0 | 02-12-2010 06:21 AM |
Classic Adobe Digital Editions 1.7.2 | jrb028 | Barnes & Noble NOOK | 1 | 02-03-2010 10:22 AM |
Adobe has new hope for e-books with Adobe Digital Editions | Alexander Turcic | News | 82 | 01-05-2010 07:14 PM |
Adobe Digital Editions | raiderkilo | Reading and Management | 3 | 11-13-2009 02:07 AM |