I'm using a clipping technique to hide content for sighted users but make it available to screen readers. It looks like this:
.accessible-hide {
position: absolute;
clip: rect(1px 1px 1px 1px);
}
And when I want to show that item again, I can give it one of these classes, depending on its original positioning:
.accessible-show-static {
/* No need to reset clip if we're resetting the position to static. */
position: static;
}
.accessible-show-relative {
/* Ditto for relative positioning. */
position: relative;
}
.accessible-show-absolute {
/* If the shown element should have absolute positioning, reset clipping. */
clip: auto;
}
This works great in most browsers, but of course in Internet Explorer 8 there's a problem! With the second class, .accessible-show-absolute
, resetting the clip
property via clip: auto
still clips to the element's box, and cuts off any children of that element that are positioned outside it (via absolute positioning or whatnot). How can I reset the clipping in a way that shows those elements?
(Note: I realise that a much tidier solution would be to simply remove the .accessible-hide
class via JavaScript, but sometimes you need do do it within CSS -- like, for example, hover or focus states:)
.submenu {
position: absolute;
clip: rect(1px 1px 1px 1px);
}
.menu-item:hover .submenu {
clip: auto;
top: 100%;
left: 0;
}