【问题标题】:Tooltip over small image小图像上的工具提示
【发布时间】:2017-07-07 14:34:10
【问题描述】:

我目前正在设置我们的论坛并已经制作了一个验证系统,但想知道如何制作一个像 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 /样式

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);
}

您是否有可能的解决方法或其他想法或建议?

【问题讨论】:

  • 您的实际期望是什么?
  • 查看我在此处列出的 Facebook 页面,然后将鼠标悬停在蓝色对勾上。
  • 好的。我现在明白了。为什么不使用引导工具提示?w3schools.com/bootstrap/bootstrap_tooltip.asp
  • 您可以使用引导工具提示,"w3schools.com/bootstrap/bootstrap_tooltip.asp" 或 opentips "jsfiddle.net/Hema_Nandagopal/671ptukx/2"
  • 顺便说一句,您可以通过将文本放在几乎任何元素的title 属性中来做一个基本的、非样式化的工具提示。这种类型的工具提示只会在鼠标悬停在元素上而不移动片刻后显示,在这种情况下您可能不希望这样做。

标签: html css tooltip


【解决方案1】:

.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>

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-01-30
  • 2012-11-14
  • 1970-01-01
  • 1970-01-01
  • 2012-02-28
  • 2012-07-27
  • 1970-01-01
相关资源
最近更新 更多