Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS transition of :first-letter on hover

I'm using :first-letter to target the first letter in a logo with some styling. On hover the colour of this letter changes.

How would I get this colour to fade in with a CSS transition? Adding the transition properties to any of my selectors doesn't seem to work.

Fiddle: http://jsfiddle.net/alecrust/YCMMZ/

Edit: Apparently Firefox 4+ is the only browser that supports the transitioning of pseudo-elements, however I'm unable to get the Fiddle above to work even in that browser.

like image 283
AlecRust Avatar asked Oct 19 '12 20:10

AlecRust


People also ask

How do you style the first letter in CSS?

The ::first-letter selector is used to add a style to the first letter of the specified selector. Note: The following properties can be used with ::first-letter: font properties. color properties.

Can I use :: first letter?

The ::first-letter CSS pseudo-element applies styles to the first letter of the first line of a block-level element, but only when not preceded by other content (such as images or inline tables).

How do I make the first letter of a paragraph big in CSS?

initial-letter is a CSS property that selects the first letter of the element where it is applied and specifies the number of lines the letter occupies. You may have seen something like this on news sites, where the first letter of a leading paragraph is larger than the rest of the content.

Which of the following is used to decorate the first letter of the paragraph?

A drop cap (dropped capital) is a large capital letter used as a decorative element at the beginning of a paragraph or section.


1 Answers

Due to poor browser support, the best way to solve this issue is to wrap your first letter in a span and give the span a class.

<header class="header">
    <h1 class="logo">
        <a href="index.html"><span class="transition">E</span>xample</a>
    </h1>
</header>​

I've updated your jsfiddle here to demonstrate: http://jsfiddle.net/YCMMZ/3/

like image 112
Jason Avatar answered Sep 25 '22 07:09

Jason