![]() |
#1 |
Junior Member
![]() Posts: 8
Karma: 10
Join Date: Dec 2014
Device: iPad, Nexus 7, iPhone 6
|
Issue formatting page with only an image.
I've been trying to get the images to behave correctly. I'm trying to create a children's ebook from just images, but the way I currently have it coded doesn't seem to work. The images show up, but they're at the top of the page. I want them to sit in the middle.
Here's some sample code: <head> <title>Audacious Little Princesses</title> <style type="text/css"> img { width: 100%} p { text-align: center; margin: 0; padding: 0; text-indent: 0 } </style> </head> <body> <div><img src="../Images/1.jpeg" alt="" /></div> </body> That's it. Here is what the output looks like: http://imgur.com/n7KhIDU Any ideas about what to do? |
![]() |
![]() |
![]() |
#2 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,761
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Hmmm, what you want is a vertically centered image. That's not easy to get
![]() 1. You need to create a .css style sheet with the following styles: Code:
html { height: 100%; /* very important */ margin: 0; } body { height: 100%; /* very important */ margin: 0; } #container1 { height: 100%; width: 100%; background: url("../Images/Obama.jpg") no-repeat 50% 50%; /* the image is the background of the "container" */ background-size: contain; /* this is important */ } Code:
<body> <div id="container1"></div> </body> Here I attach an ePub so you can see better how the things work. Vertical Centered Image.epub That's all; as you can see, images are centered, vertical and horizontally. But remember that this technique will only work on iPad or Kindle; it could not work on ADE or ereaders based on ADE. However, ADE 3.0 seems to support this solution (at least, the epub I attach looks great on ADE 3.0). Regards Rubén Last edited by RbnJrg; 12-22-2014 at 05:53 AM. |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Junior Member
![]() Posts: 8
Karma: 10
Join Date: Dec 2014
Device: iPad, Nexus 7, iPhone 6
|
Thanks for the reply. I just tried your solution (as well as the example you gave me), but it didn't work for iBooks. It just displays blank pages. It did indeed work for my android tablet and Calibre, though. Idk why that is.
Edit: (https://www.dropbox.com/s/owegx8ragx..._PEZ.epub?dl=0) This epub here works in the way I want, but when I tried emulating the html I received different results. Any idea why that may be? Last edited by blutuu; 12-22-2014 at 01:14 PM. |
![]() |
![]() |
![]() |
#4 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,761
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
Vertical Centered Image.epub Regarding your epub, is composed by images of 594 x 768px (all of them). That is ok for ereaders with a 4/3 screen but they won't be vertically aligned on ereaders with a 16/9 screen. I made some modifications on the file you uploaded (and I fixed some errors); this is the "new" version: counting_with_pez_callor_brandon.epub Watch if both versions can be open without troubles on iPad (or the ereaders you like). Regards |
|
![]() |
![]() |
![]() |
#5 |
Junior Member
![]() Posts: 8
Karma: 10
Join Date: Dec 2014
Device: iPad, Nexus 7, iPhone 6
|
Your updated files worked perfectly, but it's still not working for my own. I copied over the stylesheet and the html content, but it does not work for iBooks. Are there any other settings I should be aware of?
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,720
Karma: 145864619
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
but can it be vertically centered and have text above and below the image and none actually on the image since it's now a background?
|
![]() |
![]() |
![]() |
#7 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,761
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
counting_with_pez_callor_brandon.epub It's your epub but now with images in background. |
|
![]() |
![]() |
![]() |
#8 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,761
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
https://www.mobileread.com/forums/sho...36&postcount=4 Of course, that kind of solution only works -so far- for Kindle (those devices who support .kf8) and iPad. |
|
![]() |
![]() |
![]() |
#9 | |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,720
Karma: 145864619
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
|
|
![]() |
![]() |
![]() |
#10 |
Junior Member
![]() Posts: 8
Karma: 10
Join Date: Dec 2014
Device: iPad, Nexus 7, iPhone 6
|
It works great now, but only for iBooks. I tried it with my android tablet and the result was all over the place. I could create another version that works for other devices, but I don't know if that's best.
https://www.dropbox.com/s/yofg719jep...n%21.epub?dl=0 I found this simple ebook online. It works perfectly fine for each device I tested. I tried to see what made it work so well, but I could't figure it out. Could it deal with image sizes? |
![]() |
![]() |
![]() |
#11 |
Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 629
Karma: 1623086
Join Date: Jan 2012
Device: iPad, iPhone, Nook Simple Touch
|
A little SVG works well for me:
PHP Code:
|
![]() |
![]() |
![]() |
#12 |
Junior Member
![]() Posts: 8
Karma: 10
Join Date: Dec 2014
Device: iPad, Nexus 7, iPhone 6
|
|
![]() |
![]() |
![]() |
#13 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,761
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
|
|
![]() |
![]() |
![]() |
#14 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,761
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
That is because your others ereader doesn't support the property "background-size: contain;". In that case, and if we maintain the idea of images centered on the ereaders screen, we have to deal with the properties "display: table", "display: table-cell" and "vertical-align: middle"; but again those properties are going to be supported only by iPad and (Kf8) Kindles
![]() However if your images are always going to be of 594 x 768 then a more easy solution can be implemented. For example what you can see in this epub: counting_with_pez_callor_brandon.epub This ebook should work in any ereader ![]() |
![]() |
![]() |
![]() |
#15 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,761
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
![]() |
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Smashwords formatting issue | Flumplepuss | Writers' Corner | 2 | 11-04-2014 11:36 AM |
PB360+ Formatting issue | Japes | PocketBook | 1 | 07-15-2014 06:06 AM |
Formatting issue | jhempel24 | Sigil | 4 | 03-08-2012 01:40 PM |
Image formatting without stretching | Vanguard3000 | Sigil | 2 | 03-04-2011 01:15 AM |
image on separate page without half-page text next | Toxaris | ePub | 2 | 01-26-2011 03:32 AM |