0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-12-13 01:08:58 +01:00
Bootstrap/scss/mixins/_visually-hidden.scss
Louis-Maxime Piton 3083596e87
Some checks failed
BrowserStack / browserstack (push) Has been skipped
Bundlewatch / bundlewatch (push) Successful in 54s
CodeQL / Analyze (push) Failing after 55s
cspell / cspell (push) Successful in 24s
CSS / css (push) Successful in 42s
Docs / docs (push) Failing after 12s
JS Tests / JS Tests (push) Failing after 33s
Lint / lint (push) Successful in 34s
CSS (node-sass) / css (push) Successful in 24s
Release notes / update_release_draft (push) Has been skipped
Docs: update WCAG links and references (#40703)
Co-authored-by: Julien Déramond <juderamond@gmail.com>
2024-08-07 12:11:06 +02:00

34 lines
1.1 KiB
SCSS

// stylelint-disable declaration-no-important
// Hide content visually while keeping it accessible to assistive technologies
//
// See: https://www.a11yproject.com/posts/2013-01-11-how-to-hide-content/
// See: https://kittygiraudel.com/2016/10/13/css-hide-and-seek/
@mixin visually-hidden() {
width: 1px !important;
height: 1px !important;
padding: 0 !important;
margin: -1px !important; // Fix for https://github.com/twbs/bootstrap/issues/25686
overflow: hidden !important;
clip: rect(0, 0, 0, 0) !important;
white-space: nowrap !important;
border: 0 !important;
// Fix for positioned table caption that could become anonymous cells
&:not(caption) {
position: absolute !important;
}
}
// Use to only display content when it's focused, or one of its child elements is focused
// (i.e. when focus is within the element/container that the class was applied to)
//
// Useful for "Skip to main content" links; see https://www.w3.org/WAI/WCAG22/Techniques/general/G1.html
@mixin visually-hidden-focusable() {
&:not(:focus):not(:focus-within) {
@include visually-hidden();
}
}