Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add a tooltip to a div

I have a div tag like this:

<div>   <label>Name</label>   <input type="text"/> </div> 

How can I displaying a tooltip on :hover of the div, preferably with a fade in/out effect.

like image 569
user475685 Avatar asked Aug 19 '11 04:08

user475685


People also ask

Can a div have a tooltip?

The only thing you have to do is set an attribute on any div called "data-tooltip" and that text will be displayed next to it when you hover over it.

Can we add tooltip in CSS?

One can set a position to that tool tipped text by using CSS, which helps us to define some style and position to our tooltip. Using a tooltip to our WebPages is helps us do more interaction with the user because it gives short information of included elements.

How do I add a tooltip to a tag?

Usage. Via data attributes − To add a tooltip, add data-toggle = "tooltip" to an anchor tag. The title of the anchor will be the text of a tooltip. By default, tooltip is set to top by the plugin.

Can I put a tooltip on a span?

You can also control the position of the custom tooltip using the data-tooltip-position attribute (accepted values: top / right / bottom / left ). For instance, the following will add a tooltop positioned at the bottom of the span element.


1 Answers

For the basic tooltip, you want:

<div title="This is my tooltip"> 

like:

.visible {   height: 3em;   width: 10em;   background: yellow; }
<div title="This is my tooltip" class="visible"></div>

For a fancier javascript version, you can look into:

https://jqueryhouse.com/best-jquery-tooltip-plugins/

The above link gives you 25 options for tooltips.

like image 142
sscirrus Avatar answered Sep 18 '22 06:09

sscirrus