fade in and out on simple css tooltip

css, html

Solution

- You don't need both `:before` and `:after`.

- You have to first define `:after` content and its styles, with transition.

- Then define `:after` styles on `:hover` with only the transition properties (e.g. opacity).

Demo: http://jsfiddle.net/abhitalks/aRzA3/1/

CSS:

.tooltip:after {
    content: attr(title); /* define content here */
    ...
    opacity: 0; /* define initial transition property */
    -webkit-transition: opacity 1s ease-in-out; /* define transitions */
    transition: opacity 1s ease-in-out;
}
.tooltip:hover:after {
    opacity: 1; /* provide only the final transition property */
}

Problem

Noobish question. Trying to make a simple css tooltip to fade in and out but cant get it to work. searched a lot but couldn't find simple answer. I'm assuming i put the transition css3 in the wrong place but its not working in the others either... ``` <style> .tooltip{ display: inline; position: relative; } .tooltip:hover:after{ border-radius: 5px; bottom: 26px; content: attr(title); left: 20%; adding: 5px 15px; position: absolute; z-index: 98; width: 220px; } .tooltip:hover:before{ border-width: 6px 6px 0 6px; bottom: 20px; content: ""; left: 50%; position: absolute; z-index: 99; opacity: 0; -webkit-transition: opacity 1s ease-in-out; -moz-transition: opacity 1s ease-in-out; -ms-transition: opacity 1s ease-in-out; -o-transition: opacity 1s ease-in-out; transition: opacity 1s ease-in-out; } </style> ``` html ``` <br /><br /><br /><br /> <a href="#" title="Text text text text" class="tooltip"><span title="More">CSS3 Tooltip</span></a> ```

Original source