Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Editor

Notices

Reply
 
Thread Tools Search this Thread
Old 03-03-2020, 09:59 AM   #1
rjwse@aol.com
Addict
rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.
 
rjwse@aol.com's Avatar
 
Posts: 283
Karma: 2228060
Join Date: Dec 2013
Location: LaVernia, Texas
Device: kindle epub readers on android
9 kinds of TALLcaps/DROPcaps

I have been interested for a long time in the best ways to visually enhance epubs by adding CSS code. I have 9 different ways of making DROPcaps and here is the first. I put in all nine of them in my snippet file and can call them up in the stylesheet.css with the trigger followed by ctrl-j to expand. This first one is one of my favorite. It requires you to put class="h" in every H tag first, but lets you mix in more than a single H tag within xhtml chunks. This one lets you follow any H tag with as many as 3 other things before the P tag. Add float:left to convert TALLcap to DROPcap.

/*
NOTE: can put any number of h tags in any single xhtml segment, but every h tag MUST have class="h"
NAME: dropcap (snippet 'dc4' into stylesheet) (put class=h in all H tabs) (can put up to 3 not(p) tags between .h & p)
TRIGGER: dc4
*/

Code:
dropcapdc4,
.h+p, 
.h+:not(p)+p,
.h+:not(p)+:not(p)+p,
.h+:not(p)+:not(p)+:not(p)+p
{text-indent:0}
dropcapdc4,
.h+p:first-letter, 
.h+:not(p)+p:first-letter,
.h+:not(p)+:not(p)+p:first-letter,
.h+:not(p)+:not(p)+:not(p)+p:first-letter
{color: red;
font-size: 2em; line-height: 0.7em; float: ;}
Best regards, Pop
Attached Thumbnails
Click image for larger version

Name:	Screenshot from 2020-03-03 08-40-01.png
Views:	164
Size:	187.3 KB
ID:	177478   Click image for larger version

Name:	Screenshot from 2020-03-03 08-43-04.png
Views:	174
Size:	696.0 KB
ID:	177479  
rjwse@aol.com is offline   Reply With Quote
Old 03-03-2020, 10:05 AM   #2
stumped
Wizard
stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.stumped ought to be getting tired of karma fortunes by now.
 
Posts: 3,305
Karma: 10259306
Join Date: May 2016
Device: kobo forma, Kobo Libra, Huawei media Tab, fire HD10, PW3 HDX8.9,
my fav type of DROPcap is having NONE at ALL

1 reason I learned some html & CSS was so that I could effciently remove them before reading.
they add nothing to the reading experience, IMHO.

they are almost as useless as a dedication page
stumped is offline   Reply With Quote
Advert
Old 03-03-2020, 10:20 AM   #3
rjwse@aol.com
Addict
rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.
 
rjwse@aol.com's Avatar
 
Posts: 283
Karma: 2228060
Join Date: Dec 2013
Location: LaVernia, Texas
Device: kindle epub readers on android
dc1

/*
NAME: dropcap (snippet 'dc1' into stylesheet, then type class="dc" in xhtml) (use ANYTIME for single-instance SINGLE-LETTER dc, usually after p in <p>)
TRIGGER: dc1
*/
Code:
dropcapsnippetdc1, .dc:first-letter {color:red; display: inline; font-weight:; font-size: 2em; line-height: .7; float:none;}
dropcapsnippetdc1, .dc{text-indent:0}
This one can be used one at a time anywhere, includes quotes, but is limited to single-letter. Best regards, Pop
Attached Thumbnails
Click image for larger version

Name:	Screenshot from 2020-03-03 09-14-59.png
Views:	137
Size:	540.3 KB
ID:	177480   Click image for larger version

Name:	Screenshot from 2020-03-03 09-15-06.png
Views:	142
Size:	613.9 KB
ID:	177481   Click image for larger version

Name:	Screenshot from 2020-03-03 09-15-36.png
Views:	145
Size:	397.4 KB
ID:	177482   Click image for larger version

Name:	Screenshot from 2020-03-03 09-15-41.png
Views:	144
Size:	148.4 KB
ID:	177483  
rjwse@aol.com is offline   Reply With Quote
Old 03-03-2020, 10:32 AM   #4
rjwse@aol.com
Addict
rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.
 
rjwse@aol.com's Avatar
 
Posts: 283
Karma: 2228060
Join Date: Dec 2013
Location: LaVernia, Texas
Device: kindle epub readers on android
dc2

style="text-indent:0"><span style="font-size:2em;line-height:.7;float:none;color:red">$1</span>

This lets you make multi-letter dropcaps by adding the style command to any p tag. Best regards, Pop
Attached Thumbnails
Click image for larger version

Name:	Screenshot from 2020-03-03 09-22-28.png
Views:	132
Size:	378.9 KB
ID:	177484   Click image for larger version

Name:	Screenshot from 2020-03-03 09-22-39.png
Views:	147
Size:	141.2 KB
ID:	177485   Click image for larger version

Name:	Screenshot from 2020-03-03 09-26-14.png
Views:	150
Size:	632.9 KB
ID:	177486  
rjwse@aol.com is offline   Reply With Quote
Old 03-03-2020, 10:33 AM   #5
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 73,931
Karma: 128903250
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
You aren't showing us dropcaps. You are showing us a larger first letter. And your code doesn't work well on a Kindle. Also, your code won't work on some ePub reading software when used for section breaks if the section break happens at the end/beginning of the screen.
JSWolf is offline   Reply With Quote
Advert
Old 03-03-2020, 10:36 AM   #6
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 73,931
Karma: 128903250
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by rjwse@aol.com View Post
style="text-indent:0"><span style="font-size:2em;line-height:.7;float:none;color:red">$1</span>

This lets you make multi-letter dropcaps by adding the style command to any p tag. Best regards, Pop
That looks awful.
JSWolf is offline   Reply With Quote
Old 03-03-2020, 10:45 AM   #7
rjwse@aol.com
Addict
rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.
 
rjwse@aol.com's Avatar
 
Posts: 283
Karma: 2228060
Join Date: Dec 2013
Location: LaVernia, Texas
Device: kindle epub readers on android
the rest of the dtopcaps

/*
NAME: dropcap (snippet 'dc3' into stylesheet) (put class="h" in every header tag) (dc appears in EVERY <p> not preceeded by <p>) (see dc4 to exclude intervening tags)
TRIGGER: dc3
*/

Code:
dropcapsnippetdc3, .h+p {text-indent:0}
dropcapsnippetdc3, .h+p:first-letter {color: red; font-size: 2em; line-height: 0.7em;  float: ;}
NAME: dropcap (snippet 'dc5' into stylesheet) (1st letter dc in EVERY <p> not preceeded by <p>) (includes quotes, excludes superscripts)
TRIGGER: dc5
Code:
dropcapsnippetdc5, :not(p)+p{text-indent: 0;}
dropcapsnippetdc5, :not(p) +p:first-letter{ color: red; font-size: 2em; line-height: 0.7em; float: ;}
NAME: dropcap (snippet 'dc6' into stylesheet) (works for h1 & h2 even if h1 & h2 mixed inside of one xhtml)
TRIGGER: dc6
Code:
dropcapsnippetdc6, 
h1+p, 
h1+:not(p) +p, 
h1+:not(p) +:not(p) +p,
h1+:not(p) +:not(p) +:not(p) +p,
h2+p, 
h2+:not(p) +p, 
h2+:not(p) +:not(p) +p,
h2+:not(p) +:not(p) +:not(p) +p {text-indent: 0;}  
dropcapsnippetdc6, 
h1+p:first-letter, 
h1+:not(p) +p:first-letter, 
h1+:not(p) +:not(p) +p:first-letter,
h1+:not(p) +:not(p) +:not(p) +p:first-letter,
h2+p:first-letter, 
h2+:not(p) +p:first-letter, 
h2+:not(p) +:not(p) +p:first-letter,
h2+:not(p) +:not(p) +:not(p) +p:first-letter{ color: red; font-size: 2em; line-height: 0.7em; float: ;}
/*
NOTE: similar to dc4 without requiring class="h" in h tags; only works for h1 and h2
NAME: dropcap (snippet 'dc7' into stylesheet) (can put as many as 3 non-p-tags between H tag and P)
TRIGGER: dc7
*/
Code:
dropcapdsnippetdc7,
h1~p:first-of-type,
h2+p, 
h2+:not(p) +p, 
h2+:not(p) +:not(p) +p,
h2+:not(p) +:not(p) +:not(p) +p {text-indent: 0;}
dropcapsnippetdc7, /*1st-of-type:1st-letter for h1; 1st-letter lists for h2*/ 
h1~p:first-of-type:first-letter, 
h2+p:first-letter, 
h2+:not(p) +p:first-letter, 
h2+:not(p) +:not(p) +p:first-letter,
h2+:not(p) +:not(p) +:not(p) +p:first-letter{ color: red; font-size: 2em; line-height: 0.7em; float: ;}
/*
NAME: dropcap (snippet 'dc8' into stylesheet) (only 1 <h?> tags allowed per xhtml) (not affected by intervening tags between <h?> and first <p>)(for h1, h2, & h3)
TRIGGER: dc8
*/
Code:
dropcapsnippetdc8, h1~p:first-of-type, h2~p:first-of-type, h3~p:first-of-type {text-indent: 0;}
dropcapsnippetdc8,h1~p:first-letter, h2~p:first-letter, h3~p:first-letter {color: red; font-size: 2em; line-height: 0.7em; float: ;}

NAME:dropcap (snippet 'dc9' into stylesheet) (won't work if intervening non-p tags between <h1> and <p>)
TRIGGER:dc9
dropcapsnippetdc9, h1~p:first-of-type, h2+p {text-indent: 0;}
dropcapsnippetdc9, /*1st-of-type:1st-letter for h1; 1st-letter lists for h2*/
h1~p:first-of-type:first-letter, h2+p:first-letter {color: red; font-size: 2em; line-height: 0.7em; float: ;}

All this fun stuff helped me to understand a little bit about how to use styles, classes, css, etc. I hope it helps someone. Best regards, Pop
Attached Thumbnails
Click image for larger version

Name:	Screenshot from 2020-03-03 09-43-43.png
Views:	140
Size:	675.7 KB
ID:	177487  
rjwse@aol.com is offline   Reply With Quote
Old 03-03-2020, 11:00 AM   #8
rjwse@aol.com
Addict
rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.
 
rjwse@aol.com's Avatar
 
Posts: 283
Karma: 2228060
Join Date: Dec 2013
Location: LaVernia, Texas
Device: kindle epub readers on android
I just made five bucks on a bet I could get a negative/nasty withing ten minutes! But I got more than one!
rjwse@aol.com is offline   Reply With Quote
Old 03-03-2020, 11:11 AM   #9
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 20,565
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Interesting, but is it specifically related to calibre, wouldn't it be better to post it, and anything similar, in the epub code snippets (html / css) thread.

BR
BetterRed is online now   Reply With Quote
Old 03-03-2020, 11:38 AM   #10
deback
Book E d i t o r
deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.
 
Posts: 432
Karma: 288184
Join Date: May 2015
Device: Laptop
The code for what you want to do can be much simpler. And I would get rid of the red for sure. If you want just a larger first letter, here is a simple CSS code to do that. I've only named it "dropcap," so I can find it easily in my template file when fixing tons of dropcaps in books that need fixing.

.dropcap {
display: inline;
font-weight: bold;
font-size: 2em;
line-height: 0;
}
deback is offline   Reply With Quote
Old 03-03-2020, 12:36 PM   #11
Brett Merkey
Not Quite Dead
Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.
 
Posts: 194
Karma: 654170
Join Date: Jul 2015
Device: Paperwhite 4; Galaxy Tab
@rjwse:
Quote:
bet I could get a negative/nasty
Sucker bet, naturally enough. Clearly you are not afraid to use advanced CSS syntax but the selectors indicate you are classing the tags (not necessary, as you know) and this leads to lots of obscure code -- and a bit too much of it. Not fun to have such options.

No reason why you cannot relax a bit and work off the irreducible and simple structural code?
Quote:
<h2>Chapter Title</h2>
<p>This is the first sentence and it has a nice initial cap.</p>
Then launch with sibling selectors to hook the styles:
h2 ~ p:first-of-type {}
h2 ~ p:first-of-type::first-line {}
h2 ~ p:first-of-type::first-letter {}


Kick back and focus on one result that has the qualities you want. I like large initial caps, large enough to accept text-shadow effects. This gives a good excuse to rev up the first-line pseudo-element too. Find one good elegant style, modify from there, keeping the code simple.

Seems like more fun that way...
Brett Merkey is offline   Reply With Quote
Old 03-03-2020, 12:53 PM   #12
rjwse@aol.com
Addict
rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.
 
rjwse@aol.com's Avatar
 
Posts: 283
Karma: 2228060
Join Date: Dec 2013
Location: LaVernia, Texas
Device: kindle epub readers on android
The code for what you want to do can be much simpler. And I would get rid of the red for sure. If you want just a larger first letter, here is a simple CSS code to do that. I've only named it "dropcap," so I can find it easily in my template file when fixing tons of dropcaps in books that need fixing.

.dropcap {
display: inline;
font-weight: bold;
font-size: 2em;
line-height: 0;
}
__________________
With several of mine you do not have to add anything into the xhtml at all. The CSS puts the dropcap after, say, every H1 and H2. Others of them will put a dropcap after headers, OL, img, etc, as you like. Mine also will pick up initial quotation (but not following superscripts). If the book has a hundred chapters, you don't have to touch the text at all. It's just automatically put in. CSS will not allow a construction such as (h1 ~ p):first-of-type nor does it do 'first-of-class'. There is a proposed code (not yet implemented) called 'initial-letter' (instead of first-letter). It calculates size and drop automatically. Until it comes out combinators rule the day! Best regards, Pop
rjwse@aol.com is offline   Reply With Quote
Old 03-03-2020, 03:47 PM   #13
thiago.eec
Guru
thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.
 
Posts: 927
Karma: 1177583
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite
Quote:
Originally Posted by rjwse@aol.com View Post
CSS will not allow a construction such as (h1 ~ p):first-of-type nor does it do 'first-of-class'. There is a proposed code (not yet implemented) called 'initial-letter' (instead of first-letter). It calculates size and drop automatically. Until it comes out combinators rule the day! Best regards, Pop
You are making a mistake. All those selectors are valid. About the pseudo-elements, this is their valid scope:

first-letter, first-line - CSS 2
first-of-type - CSS 3

And, about the 'initial-letter' property, as you said, it is only proposed on a Draft for CSS 3.

You can check out other selectors here.
thiago.eec is offline   Reply With Quote
Old 03-03-2020, 04:08 PM   #14
rjwse@aol.com
Addict
rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.
 
rjwse@aol.com's Avatar
 
Posts: 283
Karma: 2228060
Join Date: Dec 2013
Location: LaVernia, Texas
Device: kindle epub readers on android
<body>
<h2>text</h2>
<ol>text</ol>
<p>text</p>
<h2>text</h2>
<img />
<p>text</p>
</body>

h2 ~ p:first-of-type{} will change only first p.
(h2 ~ p):first-of-type {} would change all p's (it's a 'reset') but css does not allow.
Instead, add class="h" to all H2s and
.h ~ p:first-of-type {} and this will change both p's.
no such thing as first-of-class either.
The other way to accomplish both p's being changed is to split the xhtml segment into two to isolate the H2s.

Shazam!
rjwse@aol.com is offline   Reply With Quote
Old 03-03-2020, 05:45 PM   #15
deback
Book E d i t o r
deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.
 
Posts: 432
Karma: 288184
Join Date: May 2015
Device: Laptop
Quote:
Originally Posted by rjwse@aol.com View Post
The code for what you want to do can be much simpler. And I would get rid of the red for sure. If you want just a larger first letter, here is a simple CSS code to do that. I've only named it "dropcap," so I can find it easily in my template file when fixing tons of dropcaps in books that need fixing.

.dropcap {
display: inline;
font-weight: bold;
font-size: 2em;
line-height: 0;
}
__________________
With several of mine you do not have to add anything into the xhtml at all. The CSS puts the dropcap after, say, every H1 and H2. Others of them will put a dropcap after headers, OL, img, etc, as you like. Mine also will pick up initial quotation (but not following superscripts). If the book has a hundred chapters, you don't have to touch the text at all. It's just automatically put in. CSS will not allow a construction such as (h1 ~ p):first-of-type nor does it do 'first-of-class'. There is a proposed code (not yet implemented) called 'initial-letter' (instead of first-letter). It calculates size and drop automatically. Until it comes out combinators rule the day! Best regards, Pop
You still have to enter the H1s and H2s, etc. I find it very easy to use Regex to find and replace all first letters at the beginning of each chapter. I'll keep doing it my way, since it's easier, quicker, and simpler.
deback is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Would these dropcaps work for Kindle formats? Klip Kindle Formats 0 04-11-2014 02:30 AM
Alphabet for DropCaps crutledge Workshop 23 12-05-2013 03:34 PM
AZW3 and dropcaps Jeff L Conversion 9 01-21-2013 09:12 PM
Dropcaps code wanted JSWolf ePub 22 09-19-2012 02:31 AM
CSS / dropcaps Oldpilot Sigil 49 09-17-2012 09:44 AM


All times are GMT -4. The time now is 03:22 AM.


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