Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 08-04-2012, 05: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:	354
Size:	9.3 KB
ID:	90157  
44reader is offline   Reply With Quote
Old 08-04-2012, 06: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: 7,515
Karma: 18512745
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
Advert
Old 08-04-2012, 09: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, 10:55 AM   #4
theducks
Well trained by Cats
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: 29,779
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
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, 11:00 AM   #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: 73,896
Karma: 128597114
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
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
Advert
Old 08-04-2012, 11:12 AM   #6
theducks
Well trained by Cats
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: 29,779
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
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, 11:13 AM   #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: 7,515
Karma: 18512745
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, 11:23 AM   #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, 01: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: 73,896
Karma: 128597114
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
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


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to center an image vertically GBAV ePub 31 08-01-2018 01:57 PM
Authors vertically jfbok Library Management 4 05-30-2012 12:31 PM
Center align text in epub virtual_ink ePub 23 08-31-2011 06:27 AM
Can you center vertically? bfollowell ePub 10 07-07-2011 03:19 AM
Text becomes center-aligned when converting Alfy Calibre 12 01-19-2009 12:41 AM


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


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