javascript - 将鼠标悬停在文本上时更改带有文本的指针

标签 javascript html css angular events

<分区>


想改进这个问题吗? 通过 editing this post 添加细节并澄清问题.

关闭 4 年前

在 Html 中,如果我们需要在将鼠标悬停在文本上时显示文本,它的 Css 应该是什么。 这是需要完成的任务,类似于给定的图像。 Sample of task that needs to be done

<mat-expansion-panel-header [collapsedHeight]="'40px'" [expandedHeight]="'40px'"
                                style="margin-left: 50px;border-bottom: 1px solid #4c4c4c;">
                                <mat-panel-title
                                    style="text-decoration: none;color: #FFFFFF;font-size: 15px;font-family: sans-serif;font-weight: 700;width: 209px;overflow: hidden;text-overflow: ellipsis; word-break: break-all;white-space: nowrap;"
                                    >
                                    {{category.CategoryName}}
                                </mat-panel-title>
                                <mat-panel-description *ngIf="!category.Expanded"
                                    style="margin-left: -4px;margin-right: -6px;">
                                    <mat-icon style="color: #FFFFFF;">keyboard_arrow_down</mat-icon>
                                </mat-panel-description>
                                <mat-panel-description *ngIf="category.Expanded"
                                    style="margin-left: -4px;margin-right: -6px;">
                                    <mat-icon style="color: #FFFFFF;">keyboard_arrow_up</mat-icon>
                                </mat-panel-description>
                            </mat-expansion-panel-header>

最佳答案

<!DOCTYPE html>
<html>
<style>
.tooltip {
  position: relative;
  display: inline-block;
  border-bottom: 1px dotted black;
}

.tooltip .tooltiptext {
  visibility: hidden;
  width: 120px;
  background-color: black;
  color: #fff;
  text-align: center;
  border-radius: 6px;
  padding: 5px 0;

  /* Position the tooltip */
  position: absolute;
  z-index: 1;
}

.tooltip:hover .tooltiptext {
  visibility: visible;
}
</style>
<body style="text-align:center;">

<p>Move the mouse over the text below:</p>

<div class="tooltip">Hover over me toolTip using Css
  <span class="tooltiptext">Tooltip text</span>
</div>

<p title="someText">This is a paragraph with Tooltip set using Title attribute.</p>

</body>
</html>

可以有两种不同的方式来创建“工具提示”

  1. 通过 CSS
  2. 通过使用名为 title 的属性。

以上示例将向您展示用法,有关更多详细信息和自定义,您可以访问 here .

关于javascript - 将鼠标悬停在文本上时更改带有文本的指针,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55177001/

上一篇:javascript - CSS 单击圆圈外会导致事件

下一篇:html - CSS 正在向未指定边框的 div 添加边框

相关文章:

javascript - 在 ckeditor 中切换实时预览

javascript - 如何将字符串转换为对象的属性,它也是一个对象

html - 移动友好的导航栏(不折叠)

html - CSS 与 IE8 的兼容性问题

php - 在 HTML 表格中每 n 个单元格创建一个新行

html - 无法找出我的 ul 中的额外空间 - 简单的 html

javascript - 为购物车中的商品创建有效负载数组

javascript - 读取包含 Node.JS 中对象的 JS 文件

html - CSS 忽略 div 的 id,但不忽略类

javascript - 使用 jQuery 滚动 iframe