vikrantnegi
10/22/2016 - 2:40 PM

Visually hide some text while keeping it accessible

Visually hide some text while keeping it accessible

/* For only text */
.sr-only {
  border: 0 !important;
  clip: rect(1px, 1px, 1px, 1px) !important;
  -webkit-clip-path: inset(50%) !important;
          clip-path: inset(50%) !important;
  height: 1px !important;
  overflow: hidden !important;
  padding: 0 !important;
  position: absolute !important;
  width: 1px !important;
  white-space: nowrap !important;
}


/* For focussable elemnts eg. skip links */
.sr-only-focusable:focus,
.sr-only-focusable:active {
  clip: auto !important;
  -webkit-clip-path: none !important;
          clip-path: none !important;
  height: auto !important;
  overflow: visible !important;
  width: auto !important;
  white-space: normal !important;
}

/*
Credit: http://hugogiraudel.com/2016/10/13/css-hide-and-seek/
*/