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 08-04-2012, 06:10 AM   #1
44reader
Connoisseur
44reader can extract oil from cheese44reader can extract oil from cheese44reader can extract oil from cheese44reader can extract oil from cheese44reader can extract oil from cheese44reader can extract oil from cheese44reader can extract oil from cheese44reader can extract oil from cheese44reader can extract oil from cheese
 
44reader's Avatar
 
Posts: 61
Karma: 1234
Join Date: Jun 2012
Device: none
How do you center text vertically?

How do you center text on a page, like in the attached image?

I am a complete novice at html but I guess it would involve tags like this:

<p class="P-P5">MY CENTERED TEXT</p>

and then setting top and bottom margins in the stylesheet.

Here is an entry from my current stylesheet. Can you tell me how to adjust it to get the text centred vertically as well as horizontally please?

P-P5 {
border-bottom: 0;
border-top: 0;
display: block;
font-family: "Times New Roman", serif;
font-size: 1.83333em;
font-weight: bold;
line-height: 1.2;
margin-bottom: 0;
margin-left: 0;
margin-right: 0;
margin-top: 0;
padding-bottom: 0;
padding-left: 0;
padding-right: 0;
padding-top: 0;
text-align: center
}
Attached Thumbnails
Click image for larger version

Name:	center.png
Views:	101
Size:	9.3 KB
ID:	90157  
44reader is offline   Reply With Quote
Old 08-04-2012, 07:12 AM   #2
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,309
Karma: 4898871
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
There's no way to center vertically, because there's no way to access the page's height (there's no "page", actually).

However, some tricks that assume "height: 100%" means the full screen height might work is some readers (and fail in others).
Jellby is offline   Reply With Quote
 
Advertisement
Old 08-04-2012, 10:03 AM   #3
44reader
Connoisseur
44reader can extract oil from cheese44reader can extract oil from cheese44reader can extract oil from cheese44reader can extract oil from cheese44reader can extract oil from cheese44reader can extract oil from cheese44reader can extract oil from cheese44reader can extract oil from cheese44reader can extract oil from cheese
 
44reader's Avatar
 
Posts: 61
Karma: 1234
Join Date: Jun 2012
Device: none
OK, thanks, Jellby.

So it's probably best if I don't try and center my text, just drop it down from the top of the page a bit using a top margin.

Should I specify that in ems? I'm sure that's better than using fixed dimensions e.g. inches. But can you specify a margin as a percent of the page or something?

I can only play with my results on my tiny phone and calibre's reader - otherwise I wouldn't ask and just play around with it.

Thanks.

By the way, I see in one of your books you use "vertical-align: text-top". What does vertical-align do?
44reader is offline   Reply With Quote
Old 08-04-2012, 11:55 AM   #4
theducks
Grand Sorcerer
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 15,244
Karma: 6020307
Join Date: Aug 2009
Location: (The original) Silicon Valley, USA
Device: Galaxy Tab 2, Astak Pocket Pro, K4NT
Quote:
Originally Posted by 44reader View Post
OK, thanks, Jellby.

So it's probably best if I don't try and center my text, just drop it down from the top of the page a bit using a top margin.

Should I specify that in ems? I'm sure that's better than using fixed dimensions e.g. inches. But can you specify a margin as a percent of the page or something?

I can only play with my results on my tiny phone and calibre's reader - otherwise I wouldn't ask and just play around with it.

Thanks.

By the way, I see in one of your books you use "vertical-align: text-top". What does vertical-align do?
That applies to cell contents in tables

for all attribute definitions (straight from the source) : http://www.w3.org/TR/1999/REC-html40...ttributes.html
theducks is offline   Reply With Quote
Old 08-04-2012, 12:00 PM   #5
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 38,474
Karma: 19300555
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Aura H2), Sony PRS-650, Sony PRS-T1, nook STR, iPad 1, iPhone 5
You can use a percent like 48% to have a top margin of 48% from the top of the page. That would work for what you want.

Another thing, your CSS code looks like. It came from Word. If so, do yourself a favor and keep your book out of Word. You will save yourself a lot of grief.
JSWolf is offline   Reply With Quote
Old 08-04-2012, 12:12 PM   #6
theducks
Grand Sorcerer
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 15,244
Karma: 6020307
Join Date: Aug 2009
Location: (The original) Silicon Valley, USA
Device: Galaxy Tab 2, Astak Pocket Pro, K4NT
I have been using JSWOLF's method on books for my PEz.

My current method is Trial and error to get the percentage.

Is there a calculated (forward referenced? ) way to arrive at a value?

top-margin = 50 - (.5*<the vertical size of the containing block>)%
theducks is offline   Reply With Quote
Old 08-04-2012, 12:13 PM   #7
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,309
Karma: 4898871
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by 44reader View Post
Should I specify that in ems? I'm sure that's better than using fixed dimensions e.g. inches. But can you specify a margin as a percent of the page or something?
Quote:
Originally Posted by JSWolf View Post
You can use a percent like 48% to have a top margin of 48% from the top of the page.
Yes, but according to the CSS spec, percent in margins always refers to the page width. That is, "top-margin: 48%" and "left-margin: 48%" are exactly the same size, almost half the page width. I can't say whether or not ebook readers follow the specs, though.
Jellby is offline   Reply With Quote
Old 08-04-2012, 12:23 PM   #8
44reader
Connoisseur
44reader can extract oil from cheese44reader can extract oil from cheese44reader can extract oil from cheese44reader can extract oil from cheese44reader can extract oil from cheese44reader can extract oil from cheese44reader can extract oil from cheese44reader can extract oil from cheese44reader can extract oil from cheese
 
44reader's Avatar
 
Posts: 61
Karma: 1234
Join Date: Jun 2012
Device: none
Thanks, Jellby.

If the three lines of text are slightly higher up the page than the center, that will still look good. So I'll probably just stick with 49% and even if it's 49% of the width (rather than the height) I'm sure it'll be fine.

I'm PMing you now about the whole Word issue. Then afterwards, depending on what you say, I can start or join another thread to sort myself out. PM on its way now.
44reader is offline   Reply With Quote
Old 08-06-2012, 02:52 PM   #9
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 38,474
Karma: 19300555
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Aura H2), Sony PRS-650, Sony PRS-T1, nook STR, iPad 1, iPhone 5
Quote:
Originally Posted by Jellby View Post
Yes, but according to the CSS spec, percent in margins always refers to the page width. That is, "top-margin: 48%" and "left-margin: 48%" are exactly the same size, almost half the page width. I can't say whether or not ebook readers follow the specs, though.
But I've used and seen % in the top margin and I've seen it work the way it was intended.
JSWolf 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
Authors vertically jfbok Library Management 4 05-30-2012 01:31 PM
Center align text in epub virtual_ink ePub 23 08-31-2011 07:27 AM
Can you center vertically? bfollowell ePub 10 07-07-2011 04:19 AM
How to center an image vertically GBAV ePub 23 06-16-2010 11:41 AM
Text becomes center-aligned when converting Alfy Calibre 12 01-19-2009 01:41 AM


All times are GMT -4. The time now is 01:09 AM.


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