Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a tooltip to an input box

Tags:

html

css

tooltip

I am using the CSS.Tooltips library to try an get a tooltip to show up on an input tag. I can get it to work on a p tag but not an input tag. Any ideas?

Here is link to the fiddle: http://jsfiddle.net/cwlanca/BumU5/1/

Code

[data-tip] {   position:relative;  } [data-tip]:before {   content:'';   /* hides the tooltip when not hovered */   display:none;   content:'';   display:none;   border-left: 5px solid transparent;   border-right: 5px solid transparent;   border-bottom: 5px solid #1a1a1a;   position:absolute;   top:30px;   left:35px;   z-index:8;   font-size:0;   line-height:0;   width:0;   height:0;   position:absolute;   top:30px;   left:35px;   z-index:8;   font-size:0;   line-height:0;   width:0;   height:0; } [data-tip]:after {   display:none;   content:attr(data-tip);   position:absolute;   top:35px;   left:0px;   padding:5px 8px;   background:#1a1a1a;   color:#fff;   z-index:9;   font-size: 0.75em;   height:18px;   line-height:18px;   -webkit-border-radius: 3px;   -moz-border-radius: 3px;   border-radius: 3px;   white-space:nowrap;   word-wrap:normal; } [data-tip]:hover:before, [data-tip]:hover:after {   display:block; }
<p data-tip="This is the text of the tooltip">This is a paragraph of text that has a tooltip.</p> </br> </br> </br> <input data-tip="This is the text of the tooltip" value="44"/>
like image 216
Lance Collins Avatar asked Oct 20 '13 16:10

Lance Collins


People also ask

How do I add a tooltip to a text box?

Add your tooltip by selecting the Tooltip option on the Marks shelf. Navigate to the dashboard where you want the tooltip and place the visual that you created in this blog post over the appropriate textbox. You should now have a textbox with a tooltip that appears when you hover over it.

How do I display the input field tooltip?

In the preceding style, we have given a border and border-radius etcetera. Here we have set the content attribute to content: attr(alt); this property will display the tooltip by using the alt attribute of the anchor tag. Whatever you give to the alt tag of the anchor element it will be displayed as a tooltip.

How do I insert a tooltip?

HTML: Use a container element (like <div>) and add the "tooltip" class to it. When the user mouse over this <div>, it will show the tooltip text. The tooltip text is placed inside an inline element (like <span>) with class="tooltiptext" .

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.


2 Answers

I know this is a question regarding the CSS.Tooltips library. However, for anyone else came here resulting from google search "tooltip for input box" like I did, here is the simplest way:

<input title="This is the text of the tooltip" value="44"/> 
like image 90
user227353 Avatar answered Oct 11 '22 23:10

user227353


It seems to be a bug, it work for all input type that aren't textbox (checkboxes, radio,...)

There is a quick workaround that will work.

<div data-tip="This is the text of the tooltip2">     <input type="text" name="test" value="44"/> </div> 

JsFiddle

like image 28
Justin Lessard Avatar answered Oct 12 '22 00:10

Justin Lessard