|
|
#1 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,082
Karma: 2677223
Join Date: Dec 2010
Device: Kindle 3
|
:first-letter selector support in KF8
I used the following style to format the first letter of the first paragraph after the heading: Code:
p:nth-child(2):first-letter {
font-family: sans-serif;
float: left;
font-size: 4em;
font-weight: bold;
margin-top: -0.2em;
margin-bottom: -0.2em;
margin-right: 5px;
color: red;
}
tl:dr some CSS3 styles that have so far only been available in iBooks ePubs can also be used in KF8 books. EDIT: The following pseudo classes are known to work in KF8*: Code:
:after :before :first-letter :first-line :first-of-type :last-of-type :lang(xx) :nth-child(n) :nth-child(even) :nth-child(odd) :nth-of-type(n) :only-of-type Use at your own risk! Last edited by Doitsu; 05-07-2013 at 02:47 AM. Reason: disclaimer added |
|
|
|
|
|
#2 |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,833
Karma: 23400772
Join Date: Jan 2010
Device: Kindle Fire HD, Kindle 2
|
Are you testing on real devices or Kindle Previewer?
__________________
“Politics: A strife of interests masquerading as a contest of principles. The conduct of public affairs for private advantage.” |
|
|
|
|
Enthusiast
|
|
|
|
#3 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,082
Karma: 2677223
Join Date: Dec 2010
Device: Kindle 3
|
|
|
|
|
|
|
#4 |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,833
Karma: 23400772
Join Date: Jan 2010
Device: Kindle Fire HD, Kindle 2
|
Hmmm. I wonder what the reasoning is for explicitly stating it isn't supported, then? Does it do something unspeakable on the plain mobi side of the conversion? It's one thing to have undocumented support for something, but I would think there'd be a reason of some sort for expressly saying it's not supported.
__________________
“Politics: A strife of interests masquerading as a contest of principles. The conduct of public affairs for private advantage.” Last edited by DiapDealer; 05-04-2013 at 08:24 AM. |
|
|
|
|
|
#5 | |||
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,082
Karma: 2677223
Join Date: Dec 2010
Device: Kindle 3
|
Quote:
OTOH, the publication guidelines also contains recommendations such as "Publishers can include their own font for their content. Amazon has a quality assurance process to ensure that these fonts display well on e Ink-based devices and do not impair the reading experience. Do not include the Charis font; it is replaced with a higher quality font in the Kindle Readers." I. e., whoever maintains the style guide might not be the most knowledgeable person. Quote:
![]() Quote:
|
|||
|
|
|
|
|
#6 | |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,833
Karma: 23400772
Join Date: Jan 2010
Device: Kindle Fire HD, Kindle 2
|
Quote:
__________________
“Politics: A strife of interests masquerading as a contest of principles. The conduct of public affairs for private advantage.” |
|
|
|
|
|
|
#7 | |
|
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 36
Karma: 30798
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
Code:
p:nth-child(2):first-line {
font-variant: small-caps;
font-size:1.2em
}
p:nth-child(2):first-letter {
float: left;
font-size: 4em;
font-weight: bold;
margin-top: -0.2em;
margin-bottom: -0.2em;
margin-right: 5px;
}
Code:
p:first-line {text-transform: uppercase}
You can use others properties like color, font-variant, font-size, etc., etc. and all of them work but I don't know why text-transform doesn't work. I must be doing something wrong
|
|
|
|
|
|
|
#8 | |
|
⁷⁄₉∈ᴮᴼᴿᴳ@₁₈%
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 366
Karma: 666665
Join Date: Dec 2010
Location: ♁ ᴺ₄₅°₃₀' ᵂ₇₃°₃₇' ±₆₀"
Device: K3.₄ PRS-350 SGS3 Rπ
|
Quote:
Code:
h3:nth-child(2n) {
font-family: sans-serif;
font-size: 2em;
text-align: center;
text-transform: uppercase;
text-shadow: 2px 2px 3px grey;
transform: rotate(-3deg);
-webkit-transform: rotate(-3deg);
}
h3:nth-child(2n+1) {
font-family: sans-serif;
font-size: 2em;
text-align: center;
text-transform: uppercase;
text-shadow: 2px 2px 3px grey;
transform: rotate(3deg);
-webkit-transform: rotate(3deg);
}
/* paragraph immediately following heading3 */
h3 + p {
text-indent: 0;
}
p {
margin: 0;
text-indent: 1em;
}
/* Small Caps RbnJrg: p:nth-child(2):first-line*/
h3 + p:first-line {
font-variant: small-caps;
font-size:1.2em;
font-weight: bold;
}
/* Dropcaps Doitsu p:nth-child(2):first-letter */
h3 + p:first-letter {
float: left;
font-size: 4em;
font-weight: bold;
margin-top: -0.2em;
margin-bottom: -0.2em;
margin-right: 5px;
}
Thanks for digging more into this Doitsu and RbnJrg. Interesting, if not always reliable. My mileage did vary depending on devices. eReaders manufacturers must like that « The beauty with standards is that there are so many to choose from »
Last edited by PoP; 05-06-2013 at 06:04 AM. Reason: define "chapter" |
|
|
|
|
|
|
#9 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,082
Karma: 2677223
Join Date: Dec 2010
Device: Kindle 3
|
Apparently, KF8 supports quite a number of pseudo classes. I tested a couple more of them that I thought might be useful for automatically applying styles to unformatted paragraphs and found out that at least the following pseudo classes work:
:after :before :first-letter :first-line :first-of-type :last-of-type :lang(xx) :nth-child(n) :nth-child(even) :nth-child(odd) :nth-of-type(n) :only-of-type IMHO, some of them are redundant, while others provide useful automated formatting options. For example, you can use p:first-of-type:first-letter instead of explicitly selecting the paragraph by number with p:nth-child(2):first-letter to apply a dropcap style. You can also zebra-stripe table rows with :nth-child or insert text or images with :before and :after. (I've attached the updated epub, which passes epubcheck, compiles without warnings but doesn't work with ADE, to the first post.) Note that the text and symbols displayed in red in the KFPC screenshot have been created without modifying the .html file and without embedded fonts/images. Last edited by Doitsu; 05-06-2013 at 01:14 PM. |
|
|
|
|
|
#10 | |
|
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 36
Karma: 30798
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
Amazon must have added support for them recently because I remember that not long ago I tried to use them and kindlegen gave me warning messages and not allow me to use them. Great work Doitsu!! |
|
|
|
|
|
|
#11 |
|
Enthusiast
![]() Posts: 29
Karma: 10
Join Date: Jul 2012
Device: Kindle Keyboard
|
Be very careful about making statements about what "KF8" supports. What you have discovered is what the version of webkit that is embedded in the device or app supports. That's important because there are subtle differences between the webkit versions on various KF8 capable devices and apps. I know there are differences in the types of media queries that work and I have no idea what other differences might exist.
|
|
|
|
|
|
#12 | |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,082
Karma: 2677223
Join Date: Dec 2010
Device: Kindle 3
|
Quote:
I also made sure to only include pseudo classes that KindleGen 2.8 compiles without displaying warnings. For example, both the K3 and the Kindle for PC app also support :before with auto-incrementing counters just fine, however, since KindleGen 2.8 displayed a W28002: CSS style specified in content is not supported by Kindle readers. warning for them, I didn't include them. Just to be on the safe side, I also added a short disclaimer to my initial post. |
|
|
|
|
|
|
#13 | |
|
Bookmaker & Cat Slave
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,099
Karma: 6245217
Join Date: Apr 2010
Location: Phoenix, AZ
Device: Kindle2, iPad, KindleFire and NookColor
|
Quote:
Actually, I'd note that in my opinion, K4PC is not one of the lowest common denominators. It displays some things (like the NCX) that aren't displayable on other Amazon "devices." I'd wonder if any of those would work in the Paperwhite, and, of course, with pseudo-classes like "first-letter" and child classes do you have any possibility of creating any fallback media queries for the earlier, K7 devices? Or, because K7 doesn't really "use" CSS, does any fallback coding get ignored? Just a question. (I mean, hell, last I looked, even Nook didn't support the pseudo-classes.) I'm very appreciative of the testing and the results! I'd love to use pseudo-classes and I'd really love to use the nth for table coloration, but...I think that would leave the K7 looking pretty damn barebones. We usually go to some lengths to ensure that we provide fallback styling for any K8 elements that won't "fly" on the K7, even to creating fallback styling for images that float in K8 but not in K7. I'd have to see if the fallback could indeed "fall back" and make something for the K7. Interesting. ![]() Hitch
__________________
I produce eBooks. www.booknook.biz Follow us on Twitter "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." - Red Adair |
|
|
|
|
|
|
#14 |
|
Enthusiast
![]() Posts: 29
Karma: 10
Join Date: Jul 2012
Device: Kindle Keyboard
|
Hitch,
All these work on the Paperwhite. The Amazon e-Ink devices (excepting the old KF7 ones) have all been upgraded to a webkit build of 528 (possibly higher for the Paperwhite, I haven't checked since the last update). There's no way that I have found to precisely duplicate the ":first-line" pseudo class. I've taken to wrapping x words in a span (where x is a number between 4 and 8) and styling them inside a amzn-mobi media query). |
|
|
|
|
|
#15 | |
|
Bookmaker & Cat Slave
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,099
Karma: 6245217
Join Date: Apr 2010
Location: Phoenix, AZ
Device: Kindle2, iPad, KindleFire and NookColor
|
Quote:
Hitch
__________________
I produce eBooks. www.booknook.biz Follow us on Twitter "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." - Red Adair |
|
|
|
|
![]() |
| Thread Tools | Search this Thread |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Is the Kindle Keyboard (K3) ever going to get KF8 support? | apastuszak | Amazon Kindle | 25 | 12-05-2012 02:18 PM |
| iPad Does Kindle App for iPad support KF8? | wiped | Apple Devices | 1 | 06-09-2012 01:44 PM |
| KF8 and hyphenation support | pirl8 | Kindle Developer's Corner | 7 | 06-08-2012 10:59 AM |
| KF8 conversion and support in Calibre? | Rhialto | Conversion | 19 | 01-16-2012 05:45 PM |
| kf8 support | apastuszak | Calibre | 6 | 11-25-2011 09:22 PM |