DEMO 253 悬浮层 POPOVER · 点击打开 ← 概念详情
点击展开悬浮层 ▾
悬浮层 · POPOVER

绝对定位 + z-index 悬于内容之上;锚定触发元素,可加小箭头或偏移阴影。

结构 · 13 LINES

<div class="ov-stage">
    <details>
      <summary class="tag" style="cursor:pointer">点击展开悬浮层 ▾</summary>
      <div class="pop">
        <div class="t">悬浮层 · POPOVER</div>
        <p>绝对定位 + z-index 悬于内容之上;锚定触发元素,可加小箭头或偏移阴影。</p>
      </div>
    </details>
    <div class="fake-text w80" style="margin-top:26px"></div>
    <div class="fake-text w60" style="margin-top:6px"></div>
    <div class="fake-text w40" style="margin-top:6px"></div>
    <div class="fake-text w80" style="margin-top:6px"></div>
  </div>

样式 · 本 demo 自定义 11 LINES + 共享令牌类

/* ═══ 本 demo 自定义样式 ═══ */

.ov-stage { position: relative; border: 1px dashed var(--line); padding: 18px; }
  .ov-stage details { position: relative; display: inline-block; }
  .ov-stage summary { list-style: none; cursor: pointer; }
  .ov-stage summary::-webkit-details-marker { display: none; }
  .pop {
    position: absolute; top: calc(100% + 8px); left: 0; z-index: 5; width: 230px;
    background: var(--paper); border: 1px solid var(--ink); padding: 12px 14px;
    box-shadow: 4px 4px 0 color-mix(in srgb, var(--ink) 18%, transparent);
  }
  .pop .t { font-weight: 650; font-size: 12.5px; margin-bottom: 6px; }
  .pop p { margin: 0; font-size: 12px; color: var(--ink-2); }

/* ═══ 共享令牌类 · demo 外壳已内置 ═══ */

.blk {
  background: color-mix(in srgb, var(--ink) 4%, transparent);
  border: 1px solid var(--line); border-radius: 2px;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em; color: var(--ink-2);
  padding: 10px; min-height: 34px;
}
.blk.acc {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--accent);
}
.blk.ink { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.tag {
  display: inline-block; font-family: var(--mono); font-size: 10px; letter-spacing: .08em;
  border: 1px solid var(--line); color: var(--ink-2); padding: 2px 8px;
  border-radius: 2px; background: var(--paper-2);
}
.card { background: var(--paper-2); border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.card .cv { aspect-ratio: 16/10; background: color-mix(in srgb, var(--accent) 10%, var(--paper-2)); border-bottom: 1px solid var(--line); }
.card .bd { padding: 9px 10px; }
.card .bd .t { font-weight: 600; font-size: 12.5px; }
.card .bd .m { font-family: var(--mono); font-size: 10px; color: var(--ink-3); margin-top: 2px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: color-mix(in srgb, var(--accent) 22%, var(--paper-2)); border: 1px solid var(--line);
}
.fake-text { height: 8px; background: color-mix(in srgb, var(--ink) 10%, transparent); border-radius: 1px; }
.fake-text.w60 { width: 60%; } .fake-text.w80 { width: 80%; } .fake-text.w40 { width: 40%; }
.fake-text + .fake-text { margin-top: 6px; }