I want to create a generic tooltip that can only be used pasasole parameters such as text and style.
I want to create a generic tooltip that can only be used pasasole parameters such as text and style.
As they said well in the comments there are many ways to make a tooltip. The best way (if you do not want to use a lot of code / boostrap) is with Jquery.
And well, after considering what the code would be basically just need to add the css and html
$(document).ready(function(){ $(".tooltip").css("visibility","hidden"); var mensaje = $(".tooltip-element").attr("tooltip-info"); $(".tooltip-element").prepend(''+mensaje+''); $(".tooltip-element").hover(function(){ $(this).find(".tooltip").css("visibility","visible"); },function(){ $(this).find(".tooltip").css("visibility","hidden"); }); });
CSS allows you to position the item you touch
.tooltip-element{ position: relative; display: inline-block; border-bottom: 1px dotted black; } .tooltip-element .tooltip{ visibility:hidden; position: absolute; z-index: 1; bottom: 125%; left: 50%; background-color: #555; color: #fff; margin-left: -60px; text-align: center; padding: 5px 0; }
An example text with 2 tooltips
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt.