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 03-31-2012, 11:46 AM   #1
mtrahan
Colonel Mustard
mtrahan is no ebook tyro.mtrahan is no ebook tyro.mtrahan is no ebook tyro.mtrahan is no ebook tyro.mtrahan is no ebook tyro.mtrahan is no ebook tyro.mtrahan is no ebook tyro.mtrahan is no ebook tyro.mtrahan is no ebook tyro.mtrahan is no ebook tyro.
 
mtrahan's Avatar
 
Posts: 87
Karma: 1426
Join Date: Feb 2010
Location: Montreal
Device: iPod Touch, Kindle 3, iPad 2
Centered but left align?

Dear ePub gurus,

I have a problem that I hope can be simply fixed. I'm working on a book — designed for print in InDesign — where there is a small poem at the end of a chapter, and that poem is in the center of the page but left aligned. You will understand better with an image (from the PDF output):



My question is: how to replicate something like this in the ePub version? So far, I'm just using left and right margins and aligning the text to the left, but it isn't an ideal solution... Exactly, current CSS for this poem is:

p.poem {
font-weight: normal;
font-style: normal;
font-size: 1em;
text-decoration: none;
font-variant: normal;
text-indent: 0em;
text-align: left;
margin: 0em 4.5em 0em 4.5em;
}

Any suggestions to make it look more like the original? I'm no CSS guru but I can't seem to find a better solution. Any help will be greatly appreciated.

Thanks in advance,

Michael
mtrahan is offline   Reply With Quote
Old 03-31-2012, 01:40 PM   #2
Toxaris
Wizard
Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.Toxaris ought to be getting tired of karma fortunes by now.
 
Toxaris's Avatar
 
Posts: 2,961
Karma: 3427611
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-300, PRS-T1
You could of course use a table with three columns and left-align the middle column. I don't always recommend tables, but in this case...
Toxaris is offline   Reply With Quote
Old 03-31-2012, 04:20 PM   #3
dwig
Guru
dwig ought to be getting tired of karma fortunes by now.dwig ought to be getting tired of karma fortunes by now.dwig ought to be getting tired of karma fortunes by now.dwig ought to be getting tired of karma fortunes by now.dwig ought to be getting tired of karma fortunes by now.dwig ought to be getting tired of karma fortunes by now.dwig ought to be getting tired of karma fortunes by now.dwig ought to be getting tired of karma fortunes by now.dwig ought to be getting tired of karma fortunes by now.dwig ought to be getting tired of karma fortunes by now.dwig ought to be getting tired of karma fortunes by now.
 
dwig's Avatar
 
Posts: 969
Karma: 1382338
Join Date: Dec 2004
Location: Paradise (Key West, FL)
Device: Current:Dell Venue 8 Pro, Kindle 3/WiFi - Retired:Clie UX50, T415, ...
Quote:
Originally Posted by mtrahan View Post
...My question is: how to replicate something like this in the ePub version?...
With all of the variables in terms of display width, both absolute pixels and number of characters, it will be tricky, if not impossible.

You can come close by making the poem one <p>, using <br /> to start new lines, and then wrap it in a <blockquote>. By applying a CSS style to the <blockquote> to set a left margin will get you close to a centered poem. You can also use a <div> instead of <blockquote> but that will fail if the ePub is converted to classic MOBI, at least with either KindleGen2 or calibre, as block level margins aren't supported and neither convert the <div> to a <blockquote>. <blockquote> will work adequately with either conversion but results in only the reader's default indent (~2em). KindleGen2 will do a decent job of replicating the ePub's behavior in ADE in the KF8 partition when either <blockquote> or <div> is used.
dwig is offline   Reply With Quote
Old 03-31-2012, 06:09 PM   #4
mmat1
Det
mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.
 
mmat1's Avatar
 
Posts: 960
Karma: 1131882
Join Date: Jan 2012
Location: Zischebattem
Device: Acer Lumiread
Quote:
Originally Posted by Toxaris View Post
You could of course use a table with three columns and left-align the middle column. I don't always recommend tables, but in this case...
How do you exactly center the centercolumn ?
mmat1 is offline   Reply With Quote
Old 03-31-2012, 06:18 PM   #5
mtrahan
Colonel Mustard
mtrahan is no ebook tyro.mtrahan is no ebook tyro.mtrahan is no ebook tyro.mtrahan is no ebook tyro.mtrahan is no ebook tyro.mtrahan is no ebook tyro.mtrahan is no ebook tyro.mtrahan is no ebook tyro.mtrahan is no ebook tyro.mtrahan is no ebook tyro.
 
mtrahan's Avatar
 
Posts: 87
Karma: 1426
Join Date: Feb 2010
Location: Montreal
Device: iPod Touch, Kindle 3, iPad 2
Quote:
Originally Posted by mmat1 View Post
How do you exactly center the centercolumn ?
3 columns, 33% width each I guess—unless there is a better way. Actually, I did this to solve a very similar problem last week and this morning it seems I didn't think of doing it again...

I think I will use that solution; I was just wondering if there was a very simple way I just couldn't see.

Thank you, Toxaris and dwig!
mtrahan is offline   Reply With Quote
Old 03-31-2012, 06:30 PM   #6
mmat1
Det
mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.
 
mmat1's Avatar
 
Posts: 960
Karma: 1131882
Join Date: Jan 2012
Location: Zischebattem
Device: Acer Lumiread
Quote:
Originally Posted by mtrahan View Post
3 columns, 33% width each I guess.
Yes this will center the 2nd column, but it will not center the text within (the longest line of the text to be accurate). Maybe 33% is too small for the longest line, then it will wrap (consider that the user may increase the font-size). Or it's a short line, then your text will be somewhat displaced to the left.

I would like to find a solution for me as well. By now i would still prefer your original solution with a paragraph which has a decent left margin.

I guess each solution has it's downside.
mmat1 is offline   Reply With Quote
Old 04-01-2012, 01:17 AM   #7
DaleDe
Grand Sorcerer
DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.
 
DaleDe's Avatar
 
Posts: 9,618
Karma: 5071748
Join Date: Aug 2007
Location: Grass Valley, CA
Device: EB 1150, EZ Reader, Literati, iPad 2
Well columns do not have to have equal width. You could have 3 columns with 20% 60% 20%.
DaleDe is online now   Reply With Quote
Old 04-01-2012, 06:11 AM   #8
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: 6,150
Karma: 4792399
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
It's easy, if you assign an explicit width to the block, then just add "margin-left: auto; margin-right: auto". That would be in an ideal world, but ADE just sets auto=0, which is allowed by the spec.

Last edited by Jellby; 04-01-2012 at 08:42 AM.
Jellby is online now   Reply With Quote
Old 04-01-2012, 07:48 AM   #9
HarryT
eBook Enthusiast
HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.
 
HarryT's Avatar
 
Posts: 63,494
Karma: 41548799
Join Date: Nov 2006
Location: UK
Device: PW2, iPad Retina Mini, iPhone 4, MS Surface Pro, Onyx T68, N7,
I've done this in the past with a centred, fixed-width, single-column table. It works well as long as there's no danger of the text occupying more than one page on the reader.
HarryT is online now   Reply With Quote
Old 04-01-2012, 11:12 AM   #10
mmat1
Det
mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.mmat1 ought to be getting tired of karma fortunes by now.
 
mmat1's Avatar
 
Posts: 960
Karma: 1131882
Join Date: Jan 2012
Location: Zischebattem
Device: Acer Lumiread
Quote:
Originally Posted by Jellby View Post
It's easy, if you assign an explicit width to the block, then just add "margin-left: auto; margin-right: auto". That would be in an ideal world, but ADE just sets auto=0, which is allowed by the spec.
It would be that easy, but any of my mobile devices sets auto to zero as well. The same is with a single column table.
mmat1 is offline   Reply With Quote
Old 04-01-2012, 12:11 PM   #11
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: 6,150
Karma: 4792399
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
If you set the width to a percent, you can set the margins to the appropriate percent value too.
Jellby is online now   Reply With Quote
Old 04-01-2012, 12:19 PM   #12
HarryT
eBook Enthusiast
HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.
 
HarryT's Avatar
 
Posts: 63,494
Karma: 41548799
Join Date: Nov 2006
Location: UK
Device: PW2, iPad Retina Mini, iPhone 4, MS Surface Pro, Onyx T68, N7,
Here's an example out of my "Sherlock Holmes Omnibus" which I'm using to display a newspaper advertisement in a centred table:

Code:
<DIV align=center>
<TABLE border=1>
<TBODY>
<TR>
<TD width="80%" align=center>HOWARD GARRIDEB
<BR id=KeepBr>Constructor of Agricultural Machinery
<BR id=KeepBr>Binders, reapers' steam and hand plows, drills, harrows,
<BR id=KeepBr>farmers' carts, buckboards, and all other appliances.
<BR id=KeepBr>Estimates for Artesian Wells.
<BR id=KeepBr>Apply Grosvenor Buildings, Aston.
</TD>
</TR>
</TBODY>
</TABLE>
</DIV>
In this case, the text within the table is centred, but change the "<TD width="80%" align=center>" to "<TD width="80%" align=left">" and you have what you want.
HarryT is online now   Reply With Quote
Old 04-01-2012, 12:33 PM   #13
Billi
Wizard
Billi ought to be getting tired of karma fortunes by now.Billi ought to be getting tired of karma fortunes by now.Billi ought to be getting tired of karma fortunes by now.Billi ought to be getting tired of karma fortunes by now.Billi ought to be getting tired of karma fortunes by now.Billi ought to be getting tired of karma fortunes by now.Billi ought to be getting tired of karma fortunes by now.Billi ought to be getting tired of karma fortunes by now.Billi ought to be getting tired of karma fortunes by now.Billi ought to be getting tired of karma fortunes by now.Billi ought to be getting tired of karma fortunes by now.
 
Billi's Avatar
 
Posts: 3,219
Karma: 13235489
Join Date: Jun 2009
Location: Berlin
Device: Cybook, iRex, PB, Onyx
In principle yes, but strictly speaking, no. The longest line of the poem will only be centered if its length matches exactly the table width of 80% or whatever the value. And as this also depends on the font choices of the reader I, personally, would go for the lazy variant and only set a left margin that is wide enough to make a distinction and shows that there comes something special (like a poem for instance).
Billi is offline   Reply With Quote
Old 04-01-2012, 12:40 PM   #14
HarryT
eBook Enthusiast
HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.
 
HarryT's Avatar
 
Posts: 63,494
Karma: 41548799
Join Date: Nov 2006
Location: UK
Device: PW2, iPad Retina Mini, iPhone 4, MS Surface Pro, Onyx T68, N7,
True - that's a good point! A simple "<blockquote>" may be all that's needed here.

Last edited by HarryT; 04-01-2012 at 12:43 PM.
HarryT is online now   Reply With Quote
Old 04-01-2012, 02:56 PM   #15
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: 6,150
Karma: 4792399
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Your code may work with mobi, HarryT, but in ePub, the table would not be centered (or not necessarily). If you had an <img> instead of <table>, yes, but tables are a different beast and tend to fail in every possible way, and not only because of buggy readers.

(Besides, all "id" are the same, which is forbidden.)
Jellby is online now   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
would like toc to be centered alansplace Kindle Formats 9 11-20-2011 11:47 AM
mobi toc centered alansplace Conversion 1 11-19-2011 07:45 PM
Text still full justifying on iPad, even through style says align left SamL ePub 10 10-01-2011 08:55 AM
Creator Align left, how do I do that for Kindle AThirstyMind Kindle Formats 7 06-03-2011 02:33 AM
Images...etc. aren't centered on my eReader! Please Help!!! Ephraim Sigil 14 01-03-2011 02:54 AM


All times are GMT -4. The time now is 02:29 PM.


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