css first-letter for link

2019-02-22 06:32发布

问题:

First letter pseudo class works perfect for p element but not for anchor(links). Why? How to make the first-letter style different for <a> element

a:first-letter
{
font-size:200%;
text-transform:uppercase;
color:#8A2BE2;
}

回答1:

How about this http://jsfiddle.net/raynesax/8W7FF/8/



回答2:

According to the W3 spec, the :first-letter pseudo-element only work for a block element, which a is not.

Oddly, *:first-letter caused the first letter to transform, at Chrome 14 and Firefox 3.6.23. Fiddle: http://jsfiddle.net/8W7FF/3/



回答3:

If JavaScript is an option it might be worth looking at: http://letteringjs.com (which should be fairly cross-browser compatible)