2020-06-29
1153
#css
Supun Kavinda
21189
Jun 29, 2020 â‹… 4 min read

Creating beautiful tooltips with only CSS

Supun Kavinda I started as a self-taught PHP developer before creating my own company, Hyvor. I am particularly interested in physics and machine learning.

Recent posts:

Rxjs Adoption Guide: Overview, Examples, And Alternatives

RxJS adoption guide: Overview, examples, and alternatives

Get to know RxJS features, benefits, and more to help you understand what it is, how it works, and why you should use it.

Emmanuel Odioko
Jul 26, 2024 â‹… 13 min read
Decoupling Monoliths Into Microservices With Feature Flags

Decoupling monoliths into microservices with feature flags

Explore how to effectively break down a monolithic application into microservices using feature flags and Flagsmith.

Kayode Adeniyi
Jul 25, 2024 â‹… 10 min read
Lots of multi-colored blue and purplish rectangles.

Animating dialog and popover elements with CSS @starting-style

Native dialog and popover elements have their own well-defined roles in modern-day frontend web development. Dialog elements are known to […]

Rahul Chhodde
Jul 24, 2024 â‹… 10 min read
Using Llama Index To Add Personal Data To Large Language Models

Using LlamaIndex to add personal data to LLMs

LlamaIndex provides tools for ingesting, processing, and implementing complex query workflows that combine data access with LLM prompting.

Ukeje Goodness
Jul 23, 2024 â‹… 5 min read
View all posts

15 Replies to "Creating beautiful tooltips with only CSS"

  1. There is a big issue with this tooltip.
    Actually, setting its opacity to 0 makes it disappear to the users eyes only, to to their mouse pointer.
    So, the tooltip actually shows up even though we don’t hover the triggering element, but also where the tooltip is supposed to be…

  2. I noticed this too, but I found an easy fix! Just add “visibility: hidden;” wherever it says “opacity:0;”, and add “visibility: visible;” wherever it says “opacity:1;”. Should work like a charm.

    1. This does work, but I found that it undoes the transition when you hover off the tooltip (in the case that it contains a link). So, the opacity changes over the specified time when you hover the triggering element, but “snaps” off when you unhover over it or the tooltip itself.

  3. Is there a way to do this with a list of generated items in the tooltip? I tried doing this, but the list has a bunch of text in it instead of actual line breaks. In other words, can it only be text when you use this method to make the tooltip?

  4. For reasons I haven’t figured out, if there are two items with tooltips, one immediately below the other, you can “see through” the upper one to the content of the one below it. With white text, this shows up as imperfections in the letters. The effect is much more apparent with black text on a buff yellow background. The fix is to give the tooltip class a z-index larger than anything else in the area right after “position: absolute;”

  5. I’ve also added “transition-delay: 100ms;” right after transition. I have three tooltips one below the other, and this keeps them from popping in and out if the skims over that area. An intentional hover is needed to make the tooltip disappear.

    With the small changes mentioned in the comments, I now have beautiful tooltips. Thank you,
    Supun Kavinda!

  6. This is terrific! I saw you wrote that “You can use the same method to create classes for bottom and top positions. Additionally, you’ll need to reset the top value and override the transform value accordingly,” though, and I’ve been playing with the CSS for quite awhile, but can’t fully figure out how to reset and override the CSS correctly to get top and bottom tooltips working–could you (or anyone else seeing this) let me know how I can do this? Any help would be greatly appreciated!

  7. Hi All,

    I have managed to get the box to appear at the top, however when I apply this effect to the next word in my paragraph which I also want the hover to appear, the second tooltip starts out hovering where the first tooltip was and then when it fades out, it jumps to the second word.

    How would I position the second tooltip to appear above the second word initially instead of inheriting the first tooltip position?

    Would really appreciate some feedback here.

    Thanks,

    Simon Carter

Leave a Reply