Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 03-11-2021, 10:42 AM   #1
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,759
Karma: 5706256
Join Date: Nov 2009
Device: many
Help with epub3 image alignment?

Hi All,

I am trying to create an epub3 of my father-in-law's memoirs, and I have been stumped trying to get the first figure to align to the centre of the page and keep the figcaption left aligned.

My xhtml code passes EpubCheck and my complete stylesheet passes the W3C check.


Here is a xhtml code snippet at the top of the page. This snippet comes right after the heading tag "Photo Gallery" at the start of the body tag.

Code:
  <figure class="tall">
    <img alt="Olga and Johann Wiedmann Wedding Bride and Groom" src="../Images/olga_johann_wedding.jpg"/>
    <figcaption><strong>Olga Lock and Johann Wiedmann Wedding</strong> – My parents on<strong> </strong>their wedding day in 1928.</figcaption>
  </figure>
and here are the relevant parts of the css:

Code:
figure {
    page-break-after:always;
    text-align: center;
}

figure.tall {
    width: 65%;
}

figure.wide {
    width: 95%;
}

figure img {
    width: 100%;
}

figcaption {
    text-align: left;
}
and attached is what I am seeing in Sigil's Preview. Notice that the "tall" image has not been centered on the page.

Given that this is epub3, I am trying to use the figure and figcaption tags instead of a div with the img and a p tag for the caption.

What I am doing wrong? Do I have to drop figure and figcaption use and go back to div, img and p tags? Nothing I have tried with css will align the "tall" image to the center of the page without aligning the figcaption as well.

Any hints appreciated?

KevinH
Attached Thumbnails
Click image for larger version

Name:	img_alignment_bug.png
Views:	240
Size:	292.8 KB
ID:	185862  
KevinH is online now   Reply With Quote
Old 03-11-2021, 11:19 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,548
Karma: 19500001
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Code:
figure {
    page-break-after:always;
    text-align: center;
}
means that the content of the <figure> block is centered, not that the block itself is centered in the outer container. For that you need to either:

(a) put the the <figure> inside another container, say a <div>, that is width:100% and text-align:center; or
(b) give side margins to the <figure> such that it appears centered, like margin:0 auto, or margin:0 17.5% (for figure.tall)
Jellby is offline   Reply With Quote
Advert
Old 03-11-2021, 11:22 AM   #3
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,759
Karma: 5706256
Join Date: Nov 2009
Device: many
Ah! Thank you! As you can see I am a better C++ programmer than an epub producer!

I will make those changes.

Edit:
Interestingly, wrapping each figure in a div with class "figimg" and using this style

Code:
div.figimg {
     width: 100%;
     text-align: center;
}
did nothing at all.

But your option b: using margin: 0 auto; on each tall figure worked liked a charm!

Thank you!

Last edited by KevinH; 03-11-2021 at 11:43 AM.
KevinH is online now   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Image Alignment Issues AndrewCanada Editor 2 10-06-2019 11:47 AM
Text - Image alignment problem MrB Sigil 10 11-03-2012 03:36 AM
Hello/Image and text alignment Derek R Introduce Yourself 3 06-26-2011 10:47 AM
Image alignment and spacing Derek R Kindle Formats 5 06-25-2011 12:57 PM


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


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