![]() |
#1 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 97
Karma: 44418
Join Date: Jul 2013
Location: Mostly in my own head!
Device: Kindle Fire, iPad
|
Positioning text vertically on a page
So, I was going through different threads in the forum and found a post about using divs to position text vertically on a page. It seemed like a simple solution and so excited was I that I didn't bother to read any further... off I went to try it out and wow, it really worked so well in ADE!
Unfortunately, iBooks appears to be disregarding those empty divs completely and I can't find that thread anymore. All I was trying to do was create a title page... it doesn't get simpler than that. ![]() Here's my title page: Code:
<div id="topGap"></div> <p id="bookTitle">Scaramouche</p> <p id="bookAuthor">Rafael Sabatini</p> Code:
div#topGap { margin: 0; padding: 0; height: 20%; } p#bookTitle { font-size: 2em; font-weight: bold; height: 10%; } p#bookAuthor { font-size: 1.6em; font-weight: bold; } I know I can use margins or padding to do this but changing the font size throws off the positioning. |
![]() |
![]() |
![]() |
#2 |
mostly an observer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,518
Karma: 987654
Join Date: Dec 2012
Device: Kindle
|
I think you'd do better with margin-top or margin-bottom.
And best of all, IMHO, is a gif file scanned from the print edition is there is one. That's what most (all?) Big Five publishers do. |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
|
A gif? Really? I would just use an optimized png. That can also be quite small. Almost anything is better than gif...
|
![]() |
![]() |
![]() |
#4 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,581
Karma: 11380098
Join Date: Aug 2010
Location: NE Oregon
Device: Kobo Sage, Pocketbook Era, Kobo Forma, Kindle Oasis 2
|
I've just been making most title pages as SVG with rare exception. Inkscape is my new friend! They work well, except for text to speech. I use title tags for reading apps that don't support SVG.
I *was* using a transparent PNG in an SVG wrapper, but I had problems with a number of Android reading apps that would render it as a blank page. A non-transparent PNG would work fine in such apps though. But I prefer transparency for non-e-ink devices, hence the move to SVG. P.S. Although the SVG title pages have worked on my Sony readers, Kobo readers, on Kindle (once converted) and in most Android apps, I don't own any Apple devices, so I don't know about that. There are some Android apps that have issues with display of the SVG on 4:3 ish aspect ratio tablet devices. What happens is the bottom of the image is cut and appears on the top of the next page. It's annoying as the same apps will display the exact same book images fine on a phone with the taller, narrower aspect ratio. Sent from my Nexus 7 using Tapatalk Last edited by graycyn; 06-18-2017 at 12:13 PM. |
![]() |
![]() |
![]() |
#5 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 97
Karma: 44418
Join Date: Jul 2013
Location: Mostly in my own head!
Device: Kindle Fire, iPad
|
Seems like a simple solution and probably the way I'm going to go.
Just gives me an itch, though. Vertical positioning shouldn't have to be rocket science. ![]() |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,301
Karma: 20171571
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
There are solutions to vertical spacing...I use them all the time for my title and dedication page. It relies on the "display:table" and "display:table-cell" elements without actually using a table. It allows the element - in this case the <div> - to behave like a <td> and thus use the "Verticle-align" property. It works great on some devices/apps - and IMO should be supported by all compliant devices - but you'll have to test it to make sure.
Here is what I use: Code:
CSS div.v-ctr {display:table; position:fixed; height:100%; width:100%; padding:0; margin:0; text-indent:0} div.v-ctr div {display:table-cell; vertical-align:middle; padding:0; margin:0} HTML <body> <div class="v-ctr"> <div> <p>Centered vertically</p> </div> </div> </body> Cheers, Last edited by Turtle91; 06-18-2017 at 01:02 PM. |
![]() |
![]() |
![]() |
#7 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 97
Karma: 44418
Join Date: Jul 2013
Location: Mostly in my own head!
Device: Kindle Fire, iPad
|
Thanks Turtle91. Will play around with this and test it out tonight.
I also like the idea of a transparent png... do android reading apps mean ADE? Out of curiousity, is iBooks ignoring the empty div or the height property? I've still been fiddling with it and it looks like its the height that's being ignored. Last edited by Nabodita; 06-18-2017 at 03:31 PM. Reason: Update |
![]() |
![]() |
![]() |
#8 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,301
Karma: 20171571
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
I'm not sure about iBooks. I stay away from it as much as possible. But some (many?) devices/apps specifically ignore empty elements. And the height property is difficult to pin down. What is the "height" of a scrolling window??
|
![]() |
![]() |
![]() |
#9 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,021
Karma: 90000009
Join Date: Nov 2011
Location: Charlottesville, VA
Device: Kindles
|
What you need for proper rendering is to refer to the height and width of the screen (viewport). Unfortunately vh and vw units were a fairly late addition to CSS and so are not supported by most EPUB software.
|
![]() |
![]() |
![]() |
#10 | |
mostly an observer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,518
Karma: 987654
Join Date: Dec 2012
Device: Kindle
|
Quote:
|
|
![]() |
![]() |
![]() |
#11 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,023
Karma: 144284074
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
|
![]() |
![]() |
![]() |
#12 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,023
Karma: 144284074
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
You don't use the height and/or width of the vewport. You use %. That works and you don't need to know the dimensions of the viewport.
|
![]() |
![]() |
![]() |
#13 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,021
Karma: 90000009
Join Date: Nov 2011
Location: Charlottesville, VA
Device: Kindles
|
Quote:
Actually, upon further thought the containing block should really be the same as the screen in this case. I take back the above. The vh and vw units are percentages of the screen size. "height: 25vh" makes the element 25% of the screen high. That is what is desired in this case. (It is too bad that this isn't well supported.) Last edited by jhowell; 06-19-2017 at 10:49 AM. |
|
![]() |
![]() |
![]() |
#14 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,470
Karma: 13095790
Join Date: Aug 2007
Location: Grass Valley, CA
Device: EB 1150, EZ Reader, Literati, iPad 2 & Air 2, iPhone 7
|
Quote:
GIF got a bad name due to copyright but that is all over now. Dale |
|
![]() |
![]() |
![]() |
#15 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 97
Karma: 44418
Join Date: Jul 2013
Location: Mostly in my own head!
Device: Kindle Fire, iPad
|
Update: Couldn't get the code to work in ADE; some sort of positioning is happening in iBooks but its certainly not centering vertically. Still fiddling with it, will post back with updates.
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
PDF page number positioning | TheOldFellow | Conversion | 2 | 11-10-2014 04:02 PM |
PDF page number positioning | TheOldFellow | Introduce Yourself | 0 | 11-10-2014 02:48 PM |
How do you vertically center a text? | Julius Caesar | Workshop | 9 | 09-08-2013 02:58 PM |
How do you center text vertically? | 44reader | ePub | 8 | 08-06-2012 01:52 PM |
Problem: positioning text to the bottom-right | JulienDym | ePub | 5 | 07-06-2011 09:03 AM |