【问题标题】:What is this popup thing when you hover over something? [duplicate]当您将鼠标悬停在某物上时,这个弹出的东西是什么? [复制]
【发布时间】:2021-03-12 11:08:26
【问题描述】:

基本上,我一直在尝试将这个“东西”纳入其中(我不知道该怎么称呼它)

我试过搜索 HTML 弹出窗口的东西,但结果不是我想要的。

例如,在 Minecraft wiki 中,当您将鼠标悬停在某个项目上时,会出现一个显示项目名称等的弹出窗口

那个弹出“东西”叫什么,所以我可以在网上搜索如何添加它?

【问题讨论】:

标签: javascript html css


【解决方案1】:

它被称为 CSS 工具提示,它是“一种常见的图形用户界面元素,当鼠标悬停在项目上时显示为信息文本框。它与光标一起使用,通常是指针。”维基百科

你可以在这里看到工具提示效果:

.tooltip {
  position: relative;
  display: inline-block;
  border-bottom: 1px dotted black;
}

.tooltip .tooltiptext {
  visibility: hidden;
  width: 120px;
  color: black;
  text-align: center;
  border-radius: 6px;
  padding: 5px 0;
  position: absolute;
  z-index: 1;
  border:3px solid black;
  bottom: 100%;
  left: 50%;
  margin-left: -60px;
  background-color:white;
  opacity: 0;
  transition: opacity 1s;
}

.tooltip:hover .tooltiptext {
  visibility: visible;
  opacity: 1;
}
<!DOCTYPE html>
<html>

<body style="text-align:center;">

<h1>Tooltip Example</h1>
<div class="tooltip">Hover over me
  <span class="tooltiptext">Tooltip text</span>
</div>

</body>
</html>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-10-10
    • 1970-01-01
    • 1970-01-01
    • 2013-08-12
    • 2015-06-04
    • 2011-01-22
    • 1970-01-01
    相关资源
    最近更新 更多