小图像上的工具提示

时间:2017-07-07 14:34:10

标签: html css tooltip

我目前正要设置我们的论坛并已经建立了一个验证系统,但想知道如何像Facebook一样制作工具提示。将鼠标悬停在支票图像上后,您会看到某种文字。

我已经尝试过一些方法来实现它但是没有用。

GoDaddy's Facebook Page

HTML

img标记包含以下内容:

data="BroHosting confirmed that this profile is an authentic for person, media, brand or company." class="tip"

CSS / Style

img:hover {
  color: red;
  position: relative;
}

img[data]:hover:after {
  content: attr(data);
  padding: 4px 8px;
  color: rgba(0,0,0,0.5);
  position: absolute;
  left: 0;
  top: 100%;
  white-space: nowrap;
  z-index: 2;
  border-radius: 5px ;
  background: rgba(0,0,0,0.5);
}

您是否有可能的修复或其他想法或建议?

1 个答案:

答案 0 :(得分:2)



.check {
  position: relative;
  display: inline-block;
  background-color: #5890ff;
  width: 12px;
  height: 12px;
  border-radius: 100%;
  color: #000;
  text-decoration: none;
}
.check:after {
  content: attr(data-tooltip);
  position: absolute;
  top: 0;
  left: 14px;
  width: 100px;
  background-color: #000;
  color: #FFF;
  font-family: Arial, sans-serif;
  font-size: 14px;
  padding: 5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease-in-out;
  will-change: opacity;
}

.check:hover:after {
  opacity: 1;
  pointer-events: auto;
}

<a href="#" class="check" data-tooltip="Lorem ipsum dolor sit amet"></a>
&#13;
&#13;
&#13;