如何在onblur上关闭工具提示消息?

时间:2015-09-21 06:44:34

标签: javascript html css

我尝试在移动设备上查看工具提示消息。当我单击工具提示图像时,它会显示消息,但是当我向下滚动屏幕时消息不会关闭。如何从工具提示图像中使用onblur关闭工具提示消息?以下代码在桌面浏览器中查看时工作正常,但在移动设备上无法正常工作。



/* 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>
&#13;
&#13;
&#13;

0 个答案:

没有答案