This is my solution for this:
https://gist.github.com/BryanMoslo/808f7acb1dafcd049a1aebbeef8c2755
The element overwrites the "tooltip-title" attribute with the tooltip text, and it appears when you hover the CSS cursor, I prefer this solution because I do not need to include the tooltip text as an HTML element!
#HTML <button class="tooltip" tooltip-title="Save">Hover over me</button> #CSS body{ padding: 50px; } .tooltip { position: relative; } .tooltip:before { content: attr(tooltip-title); min-width: 54px; background-color: #999999; color: #fff; font-size: 12px; border-radius: 4px; padding: 9px 0; position: absolute; top: -42px; left: 50%; margin-left: -27px; visibility: hidden; opacity: 0; transition: opacity 0.3s; } .tooltip:after { content: ""; position: absolute; top: -9px; left: 50%; margin-left: -5px; border-width: 5px; border-style: solid; border-color: #999999 transparent transparent; visibility: hidden; opacity: 0; transition: opacity 0.3s; } .tooltip:hover:before, .tooltip:hover:after{ visibility: visible; opacity: 1; }
Bryan Algutria Jul 16 '18 at 23:04 on 2018-07-16 23:04
source share