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 — 上下文檢視是相關的錨定表面,帶有指示箭頭。