|
|
#1 | ||
|
Groupie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 185
Karma: 1004070
Join Date: Jul 2010
Location: Italy
Device: Kindle for Android, Google Play Books
|
Figure captions
Based also on what I read here, I put together some code for adding simple, minimal, good looking figure captions. Both the figure and caption should be centered, with italic caption text slightly smaller than default. I would like this code to be generic, i.e. likely to work correctly across many reading systems. Here is the CSS code in the stylesheet:
Quote:
Quote:
|
||
|
|
|
|
|
#2 |
|
eBook FANatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 18,301
Karma: 16078357
Join Date: Apr 2008
Location: Alabama, USA
Device: HP ipac RX5915 Wife's Kindle
|
Very nice. Should work well in Epub. I've never tried "avoid", but I see what you are trying to do. I also avoid (
) having the image on one page and the caption on the next. I solved the problem by incorporating the caption into the image.Mobi does not recognize the CSS. Nor does it do tables well. I also avoid this by converting tables to images. I like your thinking. Charlie |
|
|
|
| Advert | |
|
|
|
|
#3 |
|
Not who you think I am...
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 374
Karma: 30283
Join Date: Jan 2010
Location: Honolulu
Device: PocketBook 360 -- Ivory
|
In my opinion, <div>s are overused by everyone. They're particularly overused by computer-generated code, because it's a simple hack.
I get why you've done it here, but classes and ids would work just as well, and would simplify your markup. For example: Code:
<img class="figure" id="figure_01" src="../Images/my-image.jpg" /> <p class="figure" id="figure_01_caption">This is the caption text.</p> Code:
img.figure {margin-left:auto; margin-right:auto; page-break-after: avoid;}
p.figure {text-align: center; text-indent: 0; font-style: italic; font-size: 80%; page-break-before: avoid;}
An even simpler structure, using generated content and adding the required alt tag: Code:
<img class="figure" alt="This is the caption text." src="../Images/my-image.jpg" /> Code:
img.figure {margin-left:auto; margin-right:auto;}
img.figure:after {
content: attr(alt);
display: block;
page-break-before: avoid;
text-align: center;
text-indent: 0;
font-style: italic;
font-size: 80%; }
$0.02 EDIT: the generated content should work -- but it isn't working for me in Firefox. Anyone with an idea as to why? Typo? Syntax? Last edited by capidamonte; 07-12-2010 at 06:49 PM. |
|
|
|
|
|
#4 | ||
|
frumious Bandersnatch
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,571
Karma: 20150435
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
Quote:
CSS (no need to use classes for things inside the figure): Code:
div.figure {text-align: center; font-style: italic; font-size: 80%; page-break-inside: avoid;}
/* these two lines should not be needed,
except to override other styles */
div.figure img {page-break-after: avoid;}
div.figure p {text-align: center; text-indent: 0; page-break-before: avoid;}
Code:
<div class="figure" id="figure-01"> <img src="../Images/my-image.jpg" /> <p>This is the caption text.</p> </div> Quote:
ADE, for instance, does not support "auto" margins. A <div> also lets you use the page-break-inside, which would work whether the caption comes below or above the image.Code:
An even simpler structure, using generated content and adding the required alt tag: |
||
|
|
|
|
|
#5 | ||
|
Groupie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 185
Karma: 1004070
Join Date: Jul 2010
Location: Italy
Device: Kindle for Android, Google Play Books
|
Quote:
Quote:
I currently focus on ePub. |
||
|
|
|
| Advert | |
|
|
|
|
#6 | |
|
eBook FANatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 18,301
Karma: 16078357
Join Date: Apr 2008
Location: Alabama, USA
Device: HP ipac RX5915 Wife's Kindle
|
Quote:
Learning to use GIMP took a while as graphic folks have there own vocabulary, but there are good books on GIMP. And It's FREE, ![]() Either way, have fun. |
|
|
|
|
|
|
#7 |
|
Not who you think I am...
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 374
Karma: 30283
Join Date: Jan 2010
Location: Honolulu
Device: PocketBook 360 -- Ivory
|
@Jellby: pretty elegant. I get the <div> thing as I said.
I also get the compromises you're suggesting for ADE and ePub. So, practical. After this many years, though, that we're still making compromises like this makes me sad. Still, sick of <div>s. Between <div>s and <span>s, cleaning up badly formatted text is frustrating. It's like people have never heard of a single other tag than <p>, <i> and <b>. |
|
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Can't figure this out, HELP! | chilady1 | 1 | 09-26-2010 01:13 AM | |
| captions and images together | detede | Apple Devices | 11 | 06-14-2010 10:00 PM |
| I'm Too Stupid To Figure It Out On My Own... | tippit78 | HanLin eBook | 3 | 03-26-2010 06:32 AM |
| Another person trying to figure it all out | tmoody | Introduce Yourself | 10 | 07-27-2009 02:09 PM |
| only 3 weeks to figure this out... | undertodetsy | Sony Reader | 10 | 02-01-2008 10:32 AM |