Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap equivalent of HTML5Boilerplate's .visuallyhidden

Is there a Twitter Bootstrap equivalent of HTML5Boilerplate's .visuallyhidden non-semantic helper class? I can't see anything similar in the CSS files. The purpose of the .visuallyhidden class is to visually hide it, but make the text available to screenreaders. Is there a different Bootstrappy approach to achieve the same goal?

// HTML5Boilerplate's non-semantic helper class
.visuallyhidden {
    border: 0;
    clip: rect(0 0 0 0);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
}  

The related Bootstrap non-semantic helper classes don't achieve the same effect:

// Some of Twitter Bootstrap's non-semantic helper classes
.hide {
    display: none;
}

.invisible {
    visibility: hidden;
}
like image 705
Prembo Avatar asked Feb 14 '13 14:02

Prembo


People also ask

What is visually hidden in bootstrap 5?

visually-hidden-focusable to visually hide an element by default, but to display it when it's focused (e.g. by a keyboard-only user). . visually-hidden-focusable can also be applied to a container–thanks to :focus-within , the container will be displayed when any child element of the container receives focus.

What is visually hidden?

Introduction. VisuallyHidden is a utility component that can be used to hide its children visually, while keeping them visible to screen readers and other assistive technology.


1 Answers

You can use the Bootstrap class .sr-only either in your HTML (non-semantic) or as a mixin. Here's the definition:

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}
like image 166
Matt Ryan Avatar answered Oct 17 '22 17:10

Matt Ryan