Skip to content

CSS: popover

.instui-popover — 一个为原生 [popover] 提供的提升表面,使用 CSS 锚点定位。

锚点定位仅在 Chromium 中可用;@supports 保护意味着在其他环境中 -placement-* 将静默失效,浏览器代理会将弹出层置于顶层并居中,而不是出错。

Source: popover.css

用法

css
@import "@pantoken/components/components.css";
@import "@pantoken/components/popover.css";

示例

html
<div class="instui-popover -placement-bottom" id="pop-1">
  <div class="instui-heading -level-h4">Share this page</div>
  <p class="instui-text -size-sm">A popover is a lightweight surface anchored to a trigger. This one uses the native <code>popover</code> attribute.</p>
</div>

结构

text
.instui-popover
  heading (component)
  text (component)
    code
flowchart TD n0[".instui-popover"]:::cssdoc-root n1(["heading"]):::cssdoc-component n2(["text"]):::cssdoc-component n3("code"):::cssdoc-part n0 --> n1 n2 --> n3 n0 --> n2 click n1 "/api/css/heading.md" click n2 "/api/css/text.md" classDef cssdoc-root stroke-width:1px; classDef cssdoc-part stroke-width:1px; classDef cssdoc-slot stroke-width:1px; classDef cssdoc-component stroke-width:1px;

修饰符

修饰符描述
.-placement-bottom位于锚点下方。
.-placement-end位于锚点的末端(inline-end)。
.-placement-start位于锚点的起始处(inline-start)。
.-placement-top位于锚点上方。

条件

类型查询描述
supports(position-area: block-end)
supports(transition-behavior: allow-discrete)

消耗代币

Token类型
--instui-border-width-sm<length>0.0625rem
--instui-color-background-elevated-surface-base<color>LightDarklight-dark(#ffffff, #171B21)
--instui-color-text-base<color>LightDarklight-dark(#273540, #F2F4F5)
--instui-component-popover-border-color<color>LightDarklight-dark(#8D959F, #6A7883)
--instui-component-popover-border-radius<length>0.75rem
--instui-elevation-abovenone | <shadow>#
--instui-spacing-space-sm<length>0.5rem

浏览器支持

  • 使用 CSS 锚点定位(position-anchor/position-area)和原生 [popover] API,两者目前均仅在 Chromium 可用;@supports 保护在其他环境中使放置无效,浏览器代理会将弹出层置于顶层并居中。

子组件

相关

  • tooltip — 工具提示是一个较小的、由悬停或聚焦触发的锚定表面。
  • context-view — 上下文视图是一个相关的、带指针的锚定表面。