Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 11-15-2015, 11:25 AM   #1
JLius
Village idiot
JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.
 
JLius's Avatar
 
Posts: 157
Karma: 519566
Join Date: Mar 2014
Location: Belgium
Device: sony PRS T-1
Align 2 images

Hi all

How do I align 2 images, so they display in the center of the page, next to each other, with a little white space in between and a bit of explanatory text under each (like, 'this is an image of...')?

Many thanks!
JLius is offline   Reply With Quote
Old 11-15-2015, 01:07 PM   #2
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,634
Karma: 8566337
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by JLius View Post
Hi all

How do I align 2 images, so they display in the center of the page, next to each other, with a little white space in between and a bit of explanatory text under each (like, 'this is an image of...')?

Many thanks!
Use a table There are others methods but with a table you'll have the two images aligned practically in any ereader. Use the following code:

1. In your .xhtml file:

Code:
  <div class="images">
    <table cellpadding="5" cellspacing="0" class="images">
      <tr>
        <td style="width: 50%"><img alt="Image" src="../Images/leopard.jpg" />This is a leopard</td>

        <td style="width: 50%"><img alt="Image" src="../Images/leopard.jpg" />This one too!</td>
      </tr>
    </table>
  </div>
Of course, your images will be different

2. In your .css stylesheet:

Code:
div.images {
    width: 80%;
    margin-bottom: 1.5em;
    margin-left: 10%;
    page-break-after: avoid;
}

table.images {
    padding-top: 1em;
    margin: 0 !important;
    text-align: center;
    text-indent: 0 !important;
    font-weight: bold;
    font-size: 0.8em; /* Change this if you want */
    font-family: serif;
}

table.images tr td img {
    width: 100%;
    height: auto;
    margin: 0;
    padding: 0;
    vertical-align: middle;
}
Here you have a screenshot of Sigil:

Click image for larger version

Name:	Image1.png
Views:	155
Size:	163.0 KB
ID:	143753

I also attach an epub file so you can understand better the things.

Regards

EDIT: You can style the table inside the .css stylesheet but don't erase cellpadding="5" cellspacing="0" (you can change the values, no problem with that) inside the table tag because otherwise the table won't show centered in ADE.
Attached Files
File Type: epub Two aligned images.epub (78.1 KB, 107 views)

Last edited by RbnJrg; 11-15-2015 at 01:18 PM.
RbnJrg is offline   Reply With Quote
Advert
Old 11-15-2015, 01:44 PM   #3
JLius
Village idiot
JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.
 
JLius's Avatar
 
Posts: 157
Karma: 519566
Join Date: Mar 2014
Location: Belgium
Device: sony PRS T-1
Thank you very much, RbnJrg!
JLius is offline   Reply With Quote
Old 11-15-2015, 01:57 PM   #4
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,634
Karma: 8566337
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by JLius View Post
Thank you very much, RbnJrg!
You are welcome
RbnJrg is offline   Reply With Quote
Old 11-21-2015, 04:32 PM   #5
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: 30,891
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Remember to think 'Box Model". It is always there
Margin: places the box
Border: defaults to 0 and is invisible
Padding: spaces things away from the border, default 0
Content: Images or text

each is controllable

put padding around the images
color the background of the outer box (fill)\

'Boxing' can be fun
theducks is offline   Reply With Quote
Advert
Old 11-22-2015, 04:50 AM   #6
JLius
Village idiot
JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.
 
JLius's Avatar
 
Posts: 157
Karma: 519566
Join Date: Mar 2014
Location: Belgium
Device: sony PRS T-1
This 'boxing', should it be done in the 'table.images tr td img' ?
JLius is offline   Reply With Quote
Old 11-24-2015, 12:19 PM   #7
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: 30,891
Karma: 60358908
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 JLius View Post
This 'boxing', should it be done in the 'table.images tr td img' ?
Box(ing) is always done. That is just the way it works.
Tables are a way of stacking boxes (on shelves) with more precision

Tables, like boxes can also have their borders show.

It take a bit to wrap your head around boxes and their cascaded results.

I only scrape the basics of CSS. Thankfully, EPUB only supports the basics
theducks is offline   Reply With Quote
Old 11-24-2015, 01:47 PM   #8
JLius
Village idiot
JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.
 
JLius's Avatar
 
Posts: 157
Karma: 519566
Join Date: Mar 2014
Location: Belgium
Device: sony PRS T-1
I only scrape the * whatever 's lower than basics*
JLius is offline   Reply With Quote
Old 11-24-2015, 02:14 PM   #9
HarryT
eBook Enthusiast
HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.
 
HarryT's Avatar
 
Posts: 85,544
Karma: 93383099
Join Date: Nov 2006
Location: UK
Device: Kindle Oasis 2, iPad Pro 10.5", iPhone 6
Tables are easy. Just need something like:

<table>
<tr>
<td>This is the first cell</td>
<td>This is the second cell</td>
</tr>
</table>

Just replace the text with images.
HarryT is offline   Reply With Quote
Old 11-24-2015, 02:25 PM   #10
JLius
Village idiot
JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.JLius ought to be getting tired of karma fortunes by now.
 
JLius's Avatar
 
Posts: 157
Karma: 519566
Join Date: Mar 2014
Location: Belgium
Device: sony PRS T-1
yeah, that far I scrape, but this:

Code:
table.images {
    padding-top: 1em;
    margin: 0 !important;
    text-align: center;
    text-indent: 0 !important;
    font-weight: bold;
    font-size: 0.8em; /* Change this if you want */
    font-family: serif;
}

table.images tr td img {
    width: 100%;
    height: auto;
    margin: 0;
    padding: 0;
    vertical-align: middle;
}
is like magic to me. I just copy paste it and am happy when it works.
JLius is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Attribute 'align' daveconifer Sigil 4 09-05-2014 10:13 AM
How to align/stretch images in the ebook knowledgecrawler Recipes 1 08-24-2014 01:04 PM
Images linked, 'Align' and 'Width' attributes sebdea Kindle Formats 2 01-17-2012 08:16 AM
need help on how to align a table to the right NASCARaddicted ePub 6 02-18-2011 01:46 PM
I can not align the text...help please! XD derfel_spain ePub 17 12-18-2010 09:45 AM


All times are GMT -4. The time now is 08:28 PM.


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