Show HN: hint.css – a tooltip library in CSS
kushagragour.in
kushagragour.in
content: attr(data-hint);
http://www.paciellogroup.com/blog/2013/01/using-the-html-tit...
http://s3.postimage.org/8d3zodcur/Screen_Shot_2013_02_04_at_...
The acceptable values are:
normal | none | [ string | uri | counter | attr(identifier) | open-quote | close-quote | no-open-quote | no-close-quote ]+ | inherit
You might think, maybe you could insert html by putting the html on an attribute and using the attr() value, but reading further:This function returns as a string the value of attribute X for the subject of the selector. The string is not parsed by the CSS processor.
[1] http://stackoverflow.com/questions/4505093/css-content-prope...
[2] http://www.w3.org/TR/CSS21/generate.html#propdef-content
On the other hand, having to include two classes seems sloppy. Why not just roll the core styles into the position classes, or include a default position in the 'hint' class?
Double dashes in class names are also annoying.
I just took a quick look at it, and it seems like a nice tooltip library.
It's fine if you have a mostly static page, so you can initialize all fo them on domready.
But if you are in a very dynamic page with pjax or a Javascript MVC app, you always have to initialize them again on any page change.
It's costly and error prone. This pure CSS solution in the other hand do not require any initialization. You put the HTML with the proper classes and it will just works.
Edit- I misunderstood how this works, I thought you actually had to add <span>s (extra markup) but it seems not! This is really great!
My only complaint is that it messes with elements if you're doing the :before/after thing for font icons.
I created something extremely similar a few months back for my day job (wow the traffic I missed out on!).
One thing I've encountered in this and in my own implementation: the hint gets blocked by iframe if it's nearby. Has anyone figured out a way to reliably have it appear over the iframe instead of under? I've been struggling with it for a while and have not figured it out.
Examples: https://gist.github.com/1309546 http://nicolasgallagher.com/about-html-semantics-front-end-a... http://csswizardry.com/2013/01/mindbemding-getting-your-head... http://engineering.appfolio.com/2012/11/16/css-architecture
I would say that they should only be used for styling and not functionality.
I started with this approach when I built our tooltip library for my company, but eventually there were just too many gotchas. We switched to using JavaScript and inserting the generated element as a child of `body`.
I'm sure there are some other caveats that would reveal themselves later even if this one is avoidable...
just the tip!