TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: Hint.css v2.0 – Pure CSS tooltip library

253 pointsby chinchangover 9 years ago

20 comments

sylvinusover 9 years ago
For those wondering, the main trick is here: <a href="https:&#x2F;&#x2F;github.com&#x2F;chinchang&#x2F;hint.css&#x2F;blob&#x2F;master&#x2F;hint.css#L65" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;chinchang&#x2F;hint.css&#x2F;blob&#x2F;master&#x2F;hint.css#L...</a><p>This creates a pseudo &quot;:after&quot; element with content set to the value of the data-hint attribute. Smart!<p><a href="https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;CSS&#x2F;attr" rel="nofollow">https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;CSS&#x2F;attr</a>
评论 #11012271 未加载
评论 #11014325 未加载
grumblestumbleover 9 years ago
I haven&#x27;t verified this, but I really doubt that this, or any other CSS-only solution, will work with elements constrained in an `overflow: hidden` block with a fixed height too short to display the tooltip. Which is a fairly common scenario when building app UIs. Most of the work done by Javascript tooltip libraries is figuring out the correct position relative to the &lt;body&gt; tag and appending the tooltip element outside of normal flow constraints.<p>Also, a good JS solution will dynamically reposition the tooltip if the requested orientation results in the tooltip being clipped by the viewport (eg. switch from right to left, top to bottom).
10dpdover 9 years ago
How accessible is this approach to screen reader users and people who rely on keyboard interaction alone?<p>Edit: A quick test reveals these tooltips are not accessible at all.
评论 #11012598 未加载
评论 #11011885 未加载
评论 #11011807 未加载
评论 #11011669 未加载
评论 #11016902 未加载
评论 #11011834 未加载
ryanneviusover 9 years ago
On one of the very first tooltips at the very top of the landing page (the download button), my Chrome v48.0.2564.97 browser renders a very thin gap between the triangle of the tooltip and the content rectangle. Not a great first impression...Is anyone else seeing this? I suspect it has something to do with pixel percentages.
评论 #11011900 未加载
评论 #11013758 未加载
评论 #11012150 未加载
评论 #11011540 未加载
评论 #11011845 未加载
评论 #11011612 未加载
ohitsdomover 9 years ago
What is going on when the tooltip first shows as blurry, then becomes clear? The most obvious example is hovering over the download button. Does CSS scale transform always behave this way?
评论 #11011879 未加载
Smudgeover 9 years ago
&gt; Small file size. Only 1.5KB minified and gzipped!<p>Well I guess everything is relative...
评论 #11012077 未加载
评论 #11011814 未加载
评论 #11012465 未加载
bevacquaover 9 years ago
Here&#x27;s an alternative I wrote a long time ago: <a href="https:&#x2F;&#x2F;github.com&#x2F;bevacqua&#x2F;hint" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;bevacqua&#x2F;hint</a><p>- Stylus or plain CSS<p>- Comes with a bit of JavaScript<p><pre><code> - Auto-docks to browser window edges - Multi-line if hint is too long - Transitions</code></pre>
porkerover 9 years ago
Good work!<p>&gt; &quot;Works in all modern browsers.&quot;<p>It&#x27;d be really helpful if you listed which browsers it&#x27;s been tested to work in.
评论 #11011678 未加载
评论 #11011675 未加载
billyhoffmanover 9 years ago
An interesting hack in minimalism. They accomplish being able to display user defined text in tooltips without JS by using content(data-attrib) in the CSS rule. I was not away that the content() rule allowed you to query other attributes on any matched tags and use them like variables
bosdevover 9 years ago
If anyone would like to try a live preview on their site, I wrapped hint.css in a quick Eager app: <a href="http:&#x2F;&#x2F;bit.ly&#x2F;202YkC5" rel="nofollow">http:&#x2F;&#x2F;bit.ly&#x2F;202YkC5</a>
评论 #11014002 未加载
tkinomover 9 years ago
Is there any demo of adding hint to &lt;a href....&gt;..&lt;&#x2F;a&gt;? In desktop browser, I can see the hover events can trigger the hints.<p>How to make it work on touch browser? Touch should trigger the &lt;a href&gt;, but I also like to see hints shows up somehow.
z3t4over 9 years ago
The tooltip should change position if it&#x27;s rendered outside the visible area!
esailijaover 9 years ago
Tooltips that flicker as you move mouse on the page feel really cheap. If you look at native tooltips, there is delay that waits for your mouse to &quot;settle&quot; to show the tooltip so that it doesn&#x27;t flicker.
评论 #11013048 未加载
steveaxover 9 years ago
There&#x27;s also a fork that allows HTML content:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;istarkov&#x2F;html-hint" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;istarkov&#x2F;html-hint</a>
starikovsover 9 years ago
Beautiful and works great! But I prefer to use stadard (alt,title) HTML tooltip :)
balls187over 9 years ago
hint--bounce doesn&#x27;t seem to work properly on Firefox 43.0.4 for OS X (El Capitan).
idover 9 years ago
Don&#x27;t we already have a title (or alt) attribute for &lt;a&gt;, &lt;img&gt;, &lt;abbr&gt; and other HTML elements?
评论 #11012864 未加载
eximiusover 9 years ago
uh. On mobile the grid is flipped?
StripeNoGoodover 9 years ago
&quot;Made with hands by Kushagra Gour in India&quot; - I like this guy, compared to all those &quot;Made with Love&quot; fuck you!
vogover 9 years ago
I wonder why all those demo-sites include JavaScript. Doesn&#x27;t this contradict their purpose of demonstrating a pure-CSS library?
评论 #11012357 未加载