Skip to main content Skip to docs navigation
View on GitHub

Visually hidden (視覺隱藏)

使用這些工具可以在視覺上隱藏元素,但元素仍可以被輔助技術使用。

可在視覺上隱藏元素,但仍允許其透過 .visually-hidden 呈現給輔助技術(例如螢幕閱讀器)。在預設的情況下,使用 .visually-hidden-focusable 可以在視覺上隱藏元素,但是當元素被聚焦時(例如,使用鍵盤的用戶)可以顯示該元素。也可以將 .visually-hidden-hidden-focusable 應用於容器中的 :focus-within,當容器的任何子元素都獲得焦點時,將顯示該容器。

Title for screen readers

Skip to main content
A container with a focusable element.
<h2 class="visually-hidden">Title for screen readers</h2>
<a class="visually-hidden-focusable" href="#content">Skip to main content</a>
<div class="visually-hidden-focusable">A container with a <a href="#">focusable element</a>.</div>

Both visually-hidden and visually-hidden-focusable can also be used as mixins.

// Usage as a mixin

.visually-hidden-title {
  @include visually-hidden;
}

.skip-navigation {
  @include visually-hidden-focusable;
}