View Single Post
Old 05-04-2013, 07:35 AM   #1
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,582
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
CSS 3 selector support in KF8

After reading PoP's post about his 2D Transforms tests support in KF8, I did some tests too and found out that KF8 actually supports the :first-letter selector even though the Kindle Publishing Guidelines say it doesn't
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;
}
The :first-letter selector makes it easy to add dropcaps to ebooks with lots of chapters in them without having to mark the first letter of the paragraph. (KF8 also supports text-transform and text-shadow as my cheesy heading example demonstrates.)

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 elements 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
:not
*Warning: Even though these features were successfully tested with an old K3, the Kindle for PC app and both KindleGen 2.8 and Calibre generated KF8 files, there's no guarantee that they'll work with all KF8 enabled devices and apps.

Use at your own risk!
Attached Thumbnails
Click image for larger version

Name:	K3.JPG
Views:	603
Size:	106.0 KB
ID:	105357   Click image for larger version

Name:	K4PC.JPG
Views:	579
Size:	79.7 KB
ID:	105358  
Attached Files
File Type: epub pseudo_firstletter.epub (10.3 KB, 486 views)

Last edited by Doitsu; 03-30-2015 at 01:16 PM. Reason: updated title
Doitsu is offline   Reply With Quote