0

I tried to view the tooltip message on mobile. When I click on the tooltip image, it does show the message, but the message does not close when I scroll down the screen. How can I close the tooltip message with onblur from the tooltip image? The following code works fine when viewed in a desktop browser, but not on mobile.

/* Add this attribute to the element that needs a tooltip */

[data-tooltip] {
  position: relative;
  z-index: 2;
  cursor: pointer;
}
/* Hide the tooltip content by default */

[data-tooltip]:before,
[data-tooltip]:after {
  visibility: hidden;
  -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
  filter: progid: DXImageTransform.Microsoft.Alpha(Opacity=0);
  opacity: 0;
  pointer-events: none;
}
/* Position tooltip above the element */

[data-tooltip]:before {
  position: absolute;
  bottom: 150%;
  left: 50%;
  margin-bottom: 5px;
  margin-left: -80px;
  padding: 7px;
  width: 160px;
  border-radius: 2px;
  border: 1px outset #C0C0C0;
  box-shadow: 3px 2px 5px #9F9F9F;
  background-color: #000;
  background-color: hsla(206, 73%, 34%, 0.9);
  color: #FFFFFF;
  content: attr(data-tooltip);
  text-align: center;
  font-size: 11px;
  font-family: "Trebuchet MS", Helvetica, sans-serif;
  font-weight: bold;
  line-height: 1.2;
}
/* Triangle hack to make tooltip look like a speech bubble */

[data-tooltip]:after {
  position: absolute;
  bottom: 150%;
  left: 50%;
  margin-left: -5px;
  width: 0;
  border-top: 5px solid #000;
  border-top: 5px solid hsla(206, 73%, 34%, 0.9);
  border-right: 5px solid transparent;
  border-left: 5px solid transparent;
  content: " ";
  font-size: 0;
  line-height: 0;
}
/* Show tooltip content on hover */

[data-tooltip]:hover:before,
[data-tooltip]:hover:after {
  visibility: visible;
  -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
  filter: progid: DXImageTransform.Microsoft.Alpha(Opacity=100);
  opacity: 1;
}
<Table border="1" width="50%" style="margin:15%;">
  <tr>
    <Td>
      <label>Age</label><a data-tooltip="This field is required. Only numeric characters.">&nbsp;&nbsp;&nbsp;<img src="http://vignette4.wikia.nocookie.net/community-sitcom/images/a/af/Question_mark.png/revision/latest?cb=20120714155934" width="10" height="10"/></a>

    </td>
    <td>
      <input type="text">
    </td>
  </tr>
  <tr height="500px">
    <Td>
      <label>H/P No:</label><a data-tooltip="This field is required. Only numeric characters.">&nbsp;&nbsp;&nbsp;<img src="http://vignette4.wikia.nocookie.net/community-sitcom/images/a/af/Question_mark.png/revision/latest?cb=20120714155934" width="10" height="10"/></a>

    </td>
    <td>
      <input type="text">
    </td>
  </tr>
</table>
TylerH
  • 20,799
  • 66
  • 75
  • 101
user3835327
  • 1,194
  • 1
  • 14
  • 44
  • You can use a close (x) button on your tooltip and let user to close the tooltip on your page. – Bengi Besçeli Sep 21 '15 at 07:25
  • Uhhh.. sorry i don't want add on the close button on tooltip .. – user3835327 Sep 21 '15 at 07:34
  • `the message does not close when I scroll down the screen` , just check whether the message is visible in viewport, if not visible then hide it using `hide()`.[how-to-tell-if-a-dom-element-is-visible-in-the-current-viewport](http://stackoverflow.com/questions/123999/how-to-tell-if-a-dom-element-is-visible-in-the-current-viewport) – J Santosh Sep 21 '15 at 07:52

0 Answers0