Skip to content

Tooltip 文字提示

用于文字提示的气泡框。

CSS样式

全部 tooltip 样式代码:

查看代码
css
/* HnuiIcon */
@import url('./icon.css');

/* 全局css变量 */

:root {
  /* #region vars-BrandColor */

  /* 品牌色 */
  --hnui-brand-color: #1f78ff;
  --hnui-brand-color1: #005ce5;
  --hnui-brand-color2: #4b83f7;
  --hnui-brand-color3: #3384ff;
  --hnui-brand-color4: #599bff;
  --hnui-brand-color5: #80b2ff;
  --hnui-brand-color6: #b2d1ff;
  --hnui-brand-color7: #cce0ff;
  --hnui-brand-color8: #d9e8ff;
  --hnui-brand-color9: #ebf3ff;
  --hnui-brand-color10: #f2f7ff;

  /* 状态颜色 */
  --hnui-brand-color-normal: var(--hnui-brand-color);
  --hnui-brand-color-hover: var(--hnui-brand-color3);
  --hnui-brand-color-active: var(--hnui-brand-color1);
  --hnui-brand-color-elected: var(--hnui-brand-color9);
  --hnui-brand-color-disabled: var(--hnui-brand-color7);

  --hnui-brand-color-disabled-border: var(--hnui-brand-color6);
  --hnui-brand-color-disabled-bg: var(--hnui-brand-color10);

  /* #endregion vars-BrandColor */

  /* #region vars-DomainColor */

  /* 功能色 */
  --hnui-success-color: #2ba471;
  --hnui-success-hover-color: #51bd90;
  --hnui-success-active-color: #2ba471;

  --hnui-warning-color: #faad14;
  --hnui-warning-hover-color: #ffc146;
  --hnui-warning-active-color: #db960b;

  --hnui-danger-color: #ff4d4d;
  --hnui-danger-hover-color: #ff7676;
  --hnui-danger-active-color: #d82a2a;

  --hnui-info-color: #8d97a6;
  --hnui-info-hover-color: #b2b7c0;
  --hnui-info-active-color: #707a89;

  /* #endregion vars-DomainColor */

  /* #region vars-NeutralColor */
  /* 中性色 */

  /* 标题文字 */
  --hnui-neutral-color-1: #2d2e33;

  /* 正文、重要信息文字、按钮文字、输入框正常状态文字等 */
  --hnui-neutral-color-2: #43454d;

  /* 内容文字、说明叙述文字 */
  --hnui-neutral-color-3: #5d606a;

  /* 提示性文字、辅助文本 */
  --hnui-neutral-color-4: #9298a0;

  /* 禁用文本 */
  --hnui-neutral-color-5: #b7bdc7;

  /* 描边格描边、输入文本描边、下拉选择描边等 */
  --hnui-neutral-color-6: #dfe2e7;

  /* 全局背景、禁用状态、分割线等 */
  --hnui-neutral-color-7: #f0f2f5;

  /* 最低颜色等 */
  --hnui-neutral-color-8: #fafbfc;

  /* #endregion vars-NeutralColor */

  /* 默认文字颜色 */
  --hnui-text-color: var(--hnui-neutral-color-2);

  --hnui-info-bg: #eceff4;
  --hnui-info-bg2: #e7e7e7;

  --hnui-color-white: #fff;
  --hnui-color-black: #000;

  --hnui-border-width: 1px;
  --hnui-border-dashed-width: 2px;
  --hnui-border-color: var(--hnui-neutral-color-6);

  --hnui-disabled-bg-color: var(--hnui-neutral-color-7);
  --hnui-disabled-color: var(--hnui-neutral-color-5);

  --hnui-control-height: 32px;
  --hnui-control-height-sm: 24px;
  --hnui-control-height-lg: 40px;

  --hnui-control-transparent: transparent;
}

.dark {
  --hnui-brand-color6: rgb(50, 59, 74);
  --hnui-brand-color7: #30353d;
  --hnui-brand-color8: #42484f;
  --hnui-brand-color9: #4c4f54;
  --hnui-brand-color10: #29292c;

  /* 中性色 */

  /* 标题文字 */
  --hnui-neutral-color-1: #c4c8dc;

  /* 正文、重要信息文字、按钮文字、输入框正常状态文字等 */
  --hnui-neutral-color-2: #b9bed3;

  /* 内容文字、说明叙述文字 */
  --hnui-neutral-color-3: #afb5c7;

  /* 提示性文字、辅助文本 */
  --hnui-neutral-color-4: #6a6f75;

  /* 禁用文本 */
  --hnui-neutral-color-5: #53565b;

  /* 描边格描边、输入文本描边、下拉选择描边等 */
  --hnui-neutral-color-6: #59595a;

  /* 全局背景、禁用状态、分割线等 */
  --hnui-neutral-color-7: #343535;

  /* 最低颜色等 */
  --hnui-neutral-color-8: #151516;

  --hnui-info-bg: #393b3d;

  --hnui-color-white: #000;
  --hnui-color-black: #fff;

  --hnui-control-transparent: transparent;
}

*,
::before,
::after {
  box-sizing: border-box;
}

body {
  color: var(--hnui-neutral-color-2);
}

/* #region vars-FontFamily */
@font-face {
  font-family: 'DIN';
  src: url('/fonts/D-DIN-PRO/D-DIN-PRO.woff2') format('woff2'),
    url('/fonts/D-DIN-PRO/D-DIN-PRO.woff') format('woff'),
    url('/fonts/D-DIN-PRO/D-DIN-PRO.ttf') format('truetype'),
    url('/fonts/D-DIN-PRO/D-DIN-PRO.eot') format('embedded-opentype'),
    url('/fonts/D-DIN-PRO/D-DIN-PRO.svg') format('svg');
  font-weight: normal;
  font-style: normal;
}

/* 使用数字字体 */
.use-font {
  font-family: DIN;
}
/* #endregion vars-FontFamily */

/* #region vars-BoxShadow */
/* 一级投影(默认向下) */
.hnui-box-shadow {
  box-shadow: 0px 6px 16px 6px rgba(0, 0, 0, 0.18);
}
.hnui-box-shadow.hover,
.hnui-box-shadow:hover {
  box-shadow: 0px 6px 16px 6px rgba(31, 120, 255, 0.18);
}

/* 二级投影(默认向下) */
.hnui-box-shadow_l2 {
  box-shadow: 0px 6px 16px 6px rgba(0, 0, 0, 0.12);
}
.hnui-box-shadow_l2.hover,
.hnui-box-shadow_l2:hover {
  box-shadow: 0px 6px 16px 6px rgba(31, 120, 255, 0.12);
}

/* 三级投影(默认向下) */
.hnui-box-shadow_l3 {
  box-shadow: 0px 6px 16px 6px rgba(0, 0, 0, 0.06);
}
.hnui-box-shadow_l3.hover,
.hnui-box-shadow_l3:hover {
  box-shadow: 0px 6px 16px 6px rgba(31, 120, 255, 0.06);
}
/* #endregion vars-BoxShadow */
css

/* ============================================
   Tooltip 基础样式
   ============================================ */
.hnui-tooltip {
  position: relative;
  display: inline-block;
  /* 定义箭头颜色变量 */
  --hnui-tooltip-bg: rgba(0, 0, 0, 0.85);
  --hnui-tooltip-color: var(--hnui-color-white);
}

/* Tooltip 内容容器 */
.hnui-tooltip-content {
  position: absolute;
  padding: 8px 12px;
  font-size: 14px;
  line-height: 22px;
  color: var(--hnui-tooltip-color);
  background-color: var(--hnui-tooltip-bg);
  border-radius: 6px;
  white-space: nowrap;
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

/* Tooltip 显示状态 */
.hnui-tooltip:hover .hnui-tooltip-content {
  opacity: 1;
  visibility: visible;
}

/* ============================================
   Tooltip 箭头
   ============================================ */
.hnui-tooltip-arrow {
  position: absolute;
  width: 0;
  height: 0;
  border-style: solid;
}

/* 不带箭头的样式 */
.hnui-tooltip-no-arrow .hnui-tooltip-arrow {
  display: none;
}

/* ============================================
   Tooltip 位置 - 顶部
   ============================================ */
/* 顶部居中 */
.hnui-tooltip-top .hnui-tooltip-content {
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
}

.hnui-tooltip-top .hnui-tooltip-arrow {
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px 6px 0 6px;
  border-color: var(--hnui-tooltip-bg) transparent transparent transparent;
}

/* 顶部左对齐 */
.hnui-tooltip-top-left .hnui-tooltip-content {
  bottom: calc(100% + 8px);
  left: 0;
}

.hnui-tooltip-top-left .hnui-tooltip-arrow {
  top: 100%;
  left: 16px;
  border-width: 6px 6px 0 6px;
  border-color: var(--hnui-tooltip-bg) transparent transparent transparent;
}

.hnui-tooltip-cursor .hnui-tooltip-content {
  position: fixed;
  pointer-events: none;
  /* 位置将通过 JavaScript 动态设置 */
  left: 0;
  top: 0;
  transform: translate(10px, 10px);
}

/* 顶部右对齐 */
.hnui-tooltip-top-right .hnui-tooltip-content {
  bottom: calc(100% + 8px);
  right: 0;
}

.hnui-tooltip-top-right .hnui-tooltip-arrow {
  top: 100%;
  right: 16px;
  border-width: 6px 6px 0 6px;
  border-color: var(--hnui-tooltip-bg) transparent transparent transparent;
}

/* ============================================
   Tooltip 位置 - 底部
   ============================================ */
/* 底部居中 */
.hnui-tooltip-bottom .hnui-tooltip-content {
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
}

.hnui-tooltip-bottom .hnui-tooltip-arrow {
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 0 6px 6px 6px;
  border-color: transparent transparent var(--hnui-tooltip-bg) transparent;
}

/* 底部左对齐 */
.hnui-tooltip-bottom-left .hnui-tooltip-content {
  top: calc(100% + 8px);
  left: 0;
}

.hnui-tooltip-bottom-left .hnui-tooltip-arrow {
  bottom: 100%;
  left: 16px;
  border-width: 0 6px 6px 6px;
  border-color: transparent transparent var(--hnui-tooltip-bg) transparent;
}

/* 底部右对齐 */
.hnui-tooltip-bottom-right .hnui-tooltip-content {
  top: calc(100% + 8px);
  right: 0;
}

.hnui-tooltip-bottom-right .hnui-tooltip-arrow {
  bottom: 100%;
  right: 16px;
  border-width: 0 6px 6px 6px;
  border-color: transparent transparent var(--hnui-tooltip-bg) transparent;
}

/* ============================================
   Tooltip 位置 - 左侧
   ============================================ */
/* 左侧居中 */
.hnui-tooltip-left .hnui-tooltip-content {
  right: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
}

.hnui-tooltip-left .hnui-tooltip-arrow {
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  border-width: 6px 0 6px 6px;
  border-color: transparent transparent transparent var(--hnui-tooltip-bg);
}

/* 左侧顶部对齐 */
.hnui-tooltip-left-top .hnui-tooltip-content {
  right: calc(100% + 8px);
  top: 0;
}

.hnui-tooltip-left-top .hnui-tooltip-arrow {
  left: 100%;
  top: 12px;
  border-width: 6px 0 6px 6px;
  border-color: transparent transparent transparent var(--hnui-tooltip-bg);
}

/* 左侧底部对齐 */
.hnui-tooltip-left-bottom .hnui-tooltip-content {
  right: calc(100% + 8px);
  bottom: 0;
}

.hnui-tooltip-left-bottom .hnui-tooltip-arrow {
  left: 100%;
  bottom: 12px;
  border-width: 6px 0 6px 6px;
  border-color: transparent transparent transparent var(--hnui-tooltip-bg);
}

/* ============================================
   Tooltip 位置 - 右侧
   ============================================ */
/* 右侧居中 */
.hnui-tooltip-right .hnui-tooltip-content {
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
}

.hnui-tooltip-right .hnui-tooltip-arrow {
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  border-width: 6px 6px 6px 0;
  border-color: transparent var(--hnui-tooltip-bg) transparent transparent;
}

/* 右侧顶部对齐 */
.hnui-tooltip-right-top .hnui-tooltip-content {
  left: calc(100% + 8px);
  top: 0;
}

.hnui-tooltip-right-top .hnui-tooltip-arrow {
  right: 100%;
  top: 12px;
  border-width: 6px 6px 6px 0;
  border-color: transparent var(--hnui-tooltip-bg) transparent transparent;
}

/* 右侧底部对齐 */
.hnui-tooltip-right-bottom .hnui-tooltip-content {
  left: calc(100% + 8px);
  bottom: 0;
}

.hnui-tooltip-right-bottom .hnui-tooltip-arrow {
  right: 100%;
  bottom: 12px;
  border-width: 6px 6px 6px 0;
  border-color: transparent var(--hnui-tooltip-bg) transparent transparent;
}

/* ============================================
   Tooltip 主题
   ============================================ */
/* 默认主题(黑色) - 已在基础样式中定义 */

/* 品牌色主题 */
.hnui-tooltip-brand {
  --hnui-tooltip-bg: var(--hnui-brand-color10);
  --hnui-tooltip-color: var(--hnui-brand-color);
}

/* 成功色主题 */
.hnui-tooltip-success {
  --hnui-tooltip-bg: #e6f7f1;
  --hnui-tooltip-color: var(--hnui-success-color);
}

/* 警告色主题 */
.hnui-tooltip-warning {
  --hnui-tooltip-bg: #fffbe6;
  --hnui-tooltip-color: var(--hnui-warning-color);
}

/* 危险色主题 */
.hnui-tooltip-danger {
  --hnui-tooltip-bg: #ffe6e6;
  --hnui-tooltip-color: var(--hnui-danger-color);
}

/* 亮色主题 */
.hnui-tooltip-light {
  --hnui-tooltip-bg: var(--hnui-color-white);
}

.hnui-tooltip-light .hnui-tooltip-content {
  color: var(--hnui-text-color);
  border: 1px solid var(--hnui-border-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

/* 亮色主题箭头边框效果 */
.hnui-tooltip-light.hnui-tooltip-top .hnui-tooltip-arrow::before,
.hnui-tooltip-light.hnui-tooltip-top-left .hnui-tooltip-arrow::before,
.hnui-tooltip-light.hnui-tooltip-top-right .hnui-tooltip-arrow::before {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 7px 7px 0 7px;
  border-style: solid;
  border-color: var(--hnui-border-color) transparent transparent transparent;
  z-index: -1;
}

/* ============================================
   跟随鼠标
   ============================================ */
.hnui-tooltip-cursor .hnui-tooltip-content {
  position: fixed;
  pointer-events: none;
}

/* === 暗色模式适配 === */
.dark .hnui-tooltip {
  --hnui-tooltip-bg: rgba(255, 255, 255, 0.9);
}

.dark .hnui-tooltip-content {
  color: var(--hnui-text-color);
}

/* 暗色模式下的主题色保持不变 */
.dark .hnui-tooltip-brand {
  --hnui-tooltip-bg: var(--hnui-brand-color);
}

.dark .hnui-tooltip-brand .hnui-tooltip-content {
  color: var(--hnui-color-white);
}

.dark .hnui-tooltip-success {
  --hnui-tooltip-bg: var(--hnui-success-color);
}

.dark .hnui-tooltip-success .hnui-tooltip-content {
  color: var(--hnui-color-white);
}

.dark .hnui-tooltip-warning {
  --hnui-tooltip-bg: var(--hnui-warning-color);
}

.dark .hnui-tooltip-warning .hnui-tooltip-content {
  color: var(--hnui-color-white);
}

.dark .hnui-tooltip-danger {
  --hnui-tooltip-bg: var(--hnui-danger-color);
}

.dark .hnui-tooltip-danger .hnui-tooltip-content {
  color: var(--hnui-color-white);
}

.dark .hnui-tooltip-light {
  --hnui-tooltip-bg: var(--hnui-neutral-color-7);
}

.dark .hnui-tooltip-light .hnui-tooltip-content {
  border-color: var(--hnui-neutral-color-6);
}
js
~(function () {
  'use strict';

  // 存储已初始化的 tooltip,避免重复初始化
  const initializedTooltips = new WeakSet();

  // Tooltip 跟随鼠标功能
  function initCursorTooltip() {
    const cursorTooltips = document.querySelectorAll('.hnui-tooltip-cursor');

    cursorTooltips.forEach(tooltip => {
      // 避免重复初始化
      if (initializedTooltips.has(tooltip)) return;
      initializedTooltips.add(tooltip);

      const content = tooltip.querySelector('.hnui-tooltip-content');

      if (!content) return;

      const handleMouseMove = (e) => {
        // 添加偏移量,避免 tooltip 直接在鼠标位置造成闪烁
        content.style.left = (e.clientX + 10) + 'px';
        content.style.top = (e.clientY + 10) + 'px';
      };

      // 直接在 tooltip 容器上监听 mousemove
      tooltip.addEventListener('mousemove', handleMouseMove);
    });
  }

  // 初始化所有 tooltip
  function init() {
    initCursorTooltip();
  }

  // DOM 加载完成后初始化
  if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', init);
  } else {
    init();
  }

  // 支持动态添加的 tooltip(使用 MutationObserver)
  if (typeof MutationObserver !== 'undefined') {
    const observer = new MutationObserver(() => {
      init();
    });

    // 延迟启动 observer,避免初始化时的大量触发
    setTimeout(() => {
      observer.observe(document.body, {
        childList: true,
        subtree: true
      });
    }, 1000);
  }
})();

类型

带箭头的文字提示
Hover me
文字提示仅展示文本内容
文字提示仅展示文本内容
不带箭头的文字提示
Hover me
文字提示仅展示文本内容
文字提示仅展示文本内容
跟随鼠标的文字提示
Move your mouse here
跟随鼠标移动
查看代码
html
<div class="hnui-tooltip hnui-tooltip-top">
  <span style="text-decoration: underline; cursor: pointer;">Hover me</span>
  <div class="hnui-tooltip-content">
    文字提示仅展示文本内容<br>文字提示仅展示文本内容
    <span class="hnui-tooltip-arrow"></span>
  </div>
</div>
html
<div class="hnui-tooltip hnui-tooltip-top hnui-tooltip-no-arrow">
  <span style="text-decoration: underline; cursor: pointer;">Hover me</span>
  <div class="hnui-tooltip-content">
    文字提示仅展示文本内容<br>文字提示仅展示文本内容
    <span class="hnui-tooltip-arrow"></span>
  </div>
</div>
html
<div
  class="hnui-tooltip hnui-tooltip-cursor hnui-tooltip-no-arrow"
  style="display: inline-block; padding: 20px; border: 1px dashed var(--hnui-border-color); border-radius: 6px;"
>
  <span style="cursor: pointer;">Move your mouse here</span>
  <div class="hnui-tooltip-content">
    跟随鼠标移动
  </div>
</div>

主题

默认
Hover me
文字提示仅展示文本内容
文字提示仅展示文本内容
品牌色
Hover me
文字提示仅展示文本内容
文字提示仅展示文本内容
成功色
Hover me
文字提示仅展示文本内容
文字提示仅展示文本内容
警告色
Hover me
文字提示仅展示文本内容
文字提示仅展示文本内容
危险色
Hover me
文字提示仅展示文本内容
文字提示仅展示文本内容
亮色
Hover me
文字提示仅展示文本内容
文字提示仅展示文本内容
查看代码
html
<div class="hnui-tooltip hnui-tooltip-top">
  <span style="text-decoration: underline; cursor: pointer;">Hover me</span>
  <div class="hnui-tooltip-content">
    文字提示仅展示文本内容<br>文字提示仅展示文本内容
    <span class="hnui-tooltip-arrow"></span>
  </div>
</div>
html
<div class="hnui-tooltip hnui-tooltip-top hnui-tooltip-brand">
  <span style="text-decoration: underline; cursor: pointer;">Hover me</span>
  <div class="hnui-tooltip-content">
    文字提示仅展示文本内容<br>文字提示仅展示文本内容
    <span class="hnui-tooltip-arrow"></span>
  </div>
</div>
html
<div class="hnui-tooltip hnui-tooltip-top hnui-tooltip-success">
  <span style="text-decoration: underline; cursor: pointer;">Hover me</span>
  <div class="hnui-tooltip-content">
    文字提示仅展示文本内容<br>文字提示仅展示文本内容
    <span class="hnui-tooltip-arrow"></span>
  </div>
</div>
html
<div class="hnui-tooltip hnui-tooltip-top hnui-tooltip-warning">
  <span style="text-decoration: underline; cursor: pointer;">Hover me</span>
  <div class="hnui-tooltip-content">
    文字提示仅展示文本内容<br>文字提示仅展示文本内容
    <span class="hnui-tooltip-arrow"></span>
  </div>
</div>
html
<div class="hnui-tooltip hnui-tooltip-top hnui-tooltip-danger">
  <span style="text-decoration: underline; cursor: pointer;">Hover me</span>
  <div class="hnui-tooltip-content">
    文字提示仅展示文本内容<br>文字提示仅展示文本内容
    <span class="hnui-tooltip-arrow"></span>
  </div>
</div>
html
<div class="hnui-tooltip hnui-tooltip-top hnui-tooltip-light">
  <span style="text-decoration: underline; cursor: pointer;">Hover me</span>
  <div class="hnui-tooltip-content">
    文字提示仅展示文本内容<br>文字提示仅展示文本内容
    <span class="hnui-tooltip-arrow"></span>
  </div>
</div>

文字提示位置

1. 顶部出现 - 左对齐
Hover me
文字提示仅展示文本内容
文字提示仅展示文本内容
1. 顶部出现 - 居中
Hover me
文字提示仅展示文本内容
文字提示仅展示文本内容
1. 顶部出现 - 右对齐
Hover me
文字提示仅展示文本内容
文字提示仅展示文本内容
2. 底部出现 - 左对齐
Hover me
文字提示仅展示文本内容
文字提示仅展示文本内容
2. 底部出现 - 居中
Hover me
文字提示仅展示文本内容
文字提示仅展示文本内容
2. 底部出现 - 右对齐
Hover me
文字提示仅展示文本内容
文字提示仅展示文本内容
3. 左侧出现 - 顶部对齐
Hover me
文字提示仅展示文本内容
文字提示仅展示文本内容
3. 左侧出现 - 居中
Hover me
文字提示仅展示文本内容
文字提示仅展示文本内容
3. 左侧出现 - 底部对齐
Hover me
文字提示仅展示文本内容
文字提示仅展示文本内容
4. 右侧出现 - 顶部对齐
Hover me
文字提示仅展示文本内容
文字提示仅展示文本内容
4. 右侧出现 - 居中
Hover me
文字提示仅展示文本内容
文字提示仅展示文本内容
4. 右侧出现 - 底部对齐
Hover me
文字提示仅展示文本内容
文字提示仅展示文本内容
5. 跟随鼠标出现
Move your mouse here
跟随鼠标移动
查看代码
html
<div class="hnui-tooltip hnui-tooltip-top-left">
  <span style="text-decoration: underline; cursor: pointer;">Hover me</span>
  <div class="hnui-tooltip-content">
    文字提示仅展示文本内容<br>文字提示仅展示文本内容
    <span class="hnui-tooltip-arrow"></span>
  </div>
</div>
html
<div class="hnui-tooltip hnui-tooltip-top">
  <span style="text-decoration: underline; cursor: pointer;">Hover me</span>
  <div class="hnui-tooltip-content">
    文字提示仅展示文本内容<br>文字提示仅展示文本内容
    <span class="hnui-tooltip-arrow"></span>
  </div>
</div>
html
<div class="hnui-tooltip hnui-tooltip-top-right">
  <span style="text-decoration: underline; cursor: pointer;">Hover me</span>
  <div class="hnui-tooltip-content">
    文字提示仅展示文本内容<br>文字提示仅展示文本内容
    <span class="hnui-tooltip-arrow"></span>
  </div>
</div>
html
<div class="hnui-tooltip hnui-tooltip-bottom-left">
  <span style="text-decoration: underline; cursor: pointer;">Hover me</span>
  <div class="hnui-tooltip-content">
    文字提示仅展示文本内容<br>文字提示仅展示文本内容
    <span class="hnui-tooltip-arrow"></span>
  </div>
</div>
html
<div class="hnui-tooltip hnui-tooltip-bottom">
  <span style="text-decoration: underline; cursor: pointer;">Hover me</span>
  <div class="hnui-tooltip-content">
    文字提示仅展示文本内容<br>文字提示仅展示文本内容
    <span class="hnui-tooltip-arrow"></span>
  </div>
</div>
html
<div class="hnui-tooltip hnui-tooltip-bottom-right">
  <span style="text-decoration: underline; cursor: pointer;">Hover me</span>
  <div class="hnui-tooltip-content">
    文字提示仅展示文本内容<br>文字提示仅展示文本内容
    <span class="hnui-tooltip-arrow"></span>
  </div>
</div>
html
<div class="hnui-tooltip hnui-tooltip-left-top">
  <span style="text-decoration: underline; cursor: pointer;">Hover me</span>
  <div class="hnui-tooltip-content">
    文字提示仅展示文本内容<br>文字提示仅展示文本内容
    <span class="hnui-tooltip-arrow"></span>
  </div>
</div>
html
<div class="hnui-tooltip hnui-tooltip-left">
  <span style="text-decoration: underline; cursor: pointer;">Hover me</span>
  <div class="hnui-tooltip-content">
    文字提示仅展示文本内容<br>文字提示仅展示文本内容
    <span class="hnui-tooltip-arrow"></span>
  </div>
</div>
html
<div class="hnui-tooltip hnui-tooltip-left-bottom">
  <span style="text-decoration: underline; cursor: pointer;">Hover me</span>
  <div class="hnui-tooltip-content">
    文字提示仅展示文本内容<br>文字提示仅展示文本内容
    <span class="hnui-tooltip-arrow"></span>
  </div>
</div>
html
<div class="hnui-tooltip hnui-tooltip-right-top">
  <span style="text-decoration: underline; cursor: pointer;">Hover me</span>
  <div class="hnui-tooltip-content">
    文字提示仅展示文本内容<br>文字提示仅展示文本内容
    <span class="hnui-tooltip-arrow"></span>
  </div>
</div>
html
<div class="hnui-tooltip hnui-tooltip-right">
  <span style="text-decoration: underline; cursor: pointer;">Hover me</span>
  <div class="hnui-tooltip-content">
    文字提示仅展示文本内容<br>文字提示仅展示文本内容
    <span class="hnui-tooltip-arrow"></span>
  </div>
</div>
html
<div class="hnui-tooltip hnui-tooltip-right-bottom">
  <span style="text-decoration: underline; cursor: pointer;">Hover me</span>
  <div class="hnui-tooltip-content">
    文字提示仅展示文本内容<br>文字提示仅展示文本内容
    <span class="hnui-tooltip-arrow"></span>
  </div>
</div>
html
<div
  class="hnui-tooltip hnui-tooltip-cursor hnui-tooltip-no-arrow"
  style="display: inline-block; padding: 20px; border: 1px dashed var(--hnui-border-color); border-radius: 6px;"
>
  <span style="cursor: pointer;">Move your mouse here</span>
  <div class="hnui-tooltip-content">
    跟随鼠标移动
  </div>
</div>

统一UI