View Single Post
Old 05-18-2013, 08:39 PM   #6
RbnJrg
Wizard
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 1,849
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by mrmikel View Post
Vertical centering is not so easy to do, especially if someone changes the font size. A consistent amount from the top might be most easily achievable.

One to a page has my vote, too, especially since poetry books are seldom very long. A playground to work with different indents, line spacing, etc, too.
Hi mrmikel;

Vertical centering is not so difficult as it seems. Try this code:

Code:
div#container {
   display: table;
   width: 500px;
   height: 700px;
   margin: 0 auto;
   padding: 18px;
   border: 5px solid red; /* Only to see the "table" */
}

div#content {
   display: table-cell;
   width: 100%;
   height: 100%;
   vertical-align: middle;
   font-size: 1.0em;
   text-align: left; /* for poetry */
   padding: 0 36px; /* not neccesary, just to see the text better */
   border: 5px solid black; /* Only to see the vertical align */
}
The "border" properties are not neccesary; I just included them in order that the centering it shows better. In order that the font-size doesn't affect the centering, margins and paddings (if any) must be in PIXELS.

The output is something like the following picture (from my K4NT):

https://www.mobileread.com/forums/att...9&d=1368923758

The key is to use two "divs", one as "table" and the other as a "table-cell". After that, you can use the property "vertical-align" that makes all the work
Attached Thumbnails
Click image for larger version

Name:	screen_shot-4939.gif
Views:	313
Size:	18.4 KB
ID:	106009  
Attached Files
File Type: epub Vertical Align.epub (2.4 KB, 222 views)

Last edited by RbnJrg; 05-18-2013 at 09:35 PM.
RbnJrg is offline   Reply With Quote