默认情况下如何显示工具提示而不将鼠标悬停在纯CSS中

UI_Dev

我有以下工具提示,当我们将div元素悬停在上面时,

默认情况下,刷新页面时需要显示工具提示

如何在纯CSS中实现它?我在这里不需要任何JavaScript内容。任何想法使其仅与CSS一起使用?

我尝试display: block;从中删除tooltip:before但没有一个起作用。

.toolwrapper {
  color: #555;
  cursor: help;
  font-family: Arial;
  font-size: 12px;
  margin: 40px 64px 9px 4px;
  padding: 15px 20px;
  position: relative;
  text-align: center;
  width: 100%;

}

.toolwrapper .tooltip {
  background: #424242;
  bottom: 100%;
  color: #fff;
  display: block;
  left: 0;
  opacity: 0;
  padding: 10px;
  pointer-events: none;
  position: absolute;
  width: 100%;
  -webkit-transform: translateY(10px);
     -moz-transform: translateY(10px);
      -ms-transform: translateY(10px);
       -o-transform: translateY(10px);
          transform: translateY(10px);
  -webkit-transition: all .25s ease-out;
     -moz-transition: all .25s ease-out;
      -ms-transition: all .25s ease-out;
       -o-transition: all .25s ease-out;
          transition: all .25s ease-out;
  -webkit-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
     -moz-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
      -ms-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
       -o-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
          box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
}

/* This bridges the gap so you can mouse into the tooltip without it disappearing */
.toolwrapper .tooltip:before {
  bottom: -20px;
  content: " ";
  display: block;
  height: 20px;
  left: 0;
  position: absolute;
  width: 100%;
}  


.toolwrapper .tooltip:after {
  border-left: solid transparent 10px;
  border-right: solid transparent 10px;
  border-top: solid #424242 10px;
  bottom: -10px;
  content: " ";
  height: 0;
  left: 80%;
  margin-left: -13px;
  position: absolute;
  width: 0;
}
  
.toolwrapper:hover .tooltip {
  opacity: 1;
  pointer-events: auto;
  -webkit-transform: translateY(0px);
     -moz-transform: translateY(0px);
      -ms-transform: translateY(0px);
       -o-transform: translateY(0px);
          transform: translateY(0px);
}
<div class="toolwrapper">
               Hover me to show tooltip
              <div class="tooltip">Hi I'm tooltip</div>
            </div> 

小黄瓜

您只需要在工具提示类本身上将opacityfrom更改0即可1,因为将其设置为0会使它不可见。

.toolwrapper .tooltip {
    opacity: 1;
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何在默认情况下而不是在鼠标悬停时显示地图工具提示?

为什么在不将鼠标悬停在主菜单上方的情况下显示下拉菜单?

当鼠标悬停在带有WPF的.NET中的列上时,如何显示描述的工具提示?

当鼠标悬停在数据点上时如何显示工具提示

将鼠标悬停在列表项上时如何显示工具提示?

鼠标悬停在圆环图表中的中心文本不显示工具提示

检测鼠标悬停在图例上,并在 matplotlib 中显示工具提示(标签/注释)?

PHP、JS:鼠标悬停预览不起作用,默认情况下始终显示图像

当鼠标悬停在单元格上时,如何根据单元格中存在的值在DataGridView中显示单元格的工具提示

将鼠标悬停在按钮pyqt5上时如何显示工具提示图像

使用C#(Telerik)在工具提示中显示弹出窗口或在WPF中将鼠标悬停在

如何在不单击“活动”按钮但仅将鼠标悬停在其上的情况下显示正在运行的窗口?

如何获取图片的工具提示,仅当我们将鼠标悬停在其上时才会显示。硒中

鼠标悬停在<div>中时如何显示图像?

将鼠标悬停在选项卡上时显示工具提示

鼠标悬停在折线图上时显示工具提示

在将鼠标悬停在文本上时显示工具提示

仅将鼠标悬停在单词上时限制工具提示显示

鼠标悬停在d3上的工具提示

将鼠标悬停在元素上的工具提示

如何在 p:calendar 中在鼠标悬停时显示工具提示

无论鼠标悬停如何,始终在 CanvasJS 中显示工具提示

如何在鼠标悬停时在工具提示中显示对象的值?

CSS鼠标悬停在translateXY中

工具提示:将鼠标悬停在该点时如何检索该点的位置?

iOS:当用户将鼠标悬停在UIView上时如何编写工具提示

如何始终在没有鼠标悬停的情况下在chartjs中显示标签?

仅当将鼠标悬停在文本上时,如何显示收费提示?

将鼠标悬停在内容上时,在工具提示中显示图像给我一种闪烁的效果