Use New Image Replacement Hack
Rather than text-indent: -99999px which actually forces the browser to draw that canvas use the performance savings variation of text-indent: 100% for the caret class in dropdown.less. See Zeldman.com's post today for details:
http://www.zeldman.com/2012/03/01/replacing-the-9999px-hack-new-image-replacement/
.hide-text {
text-indent: 100%;
white-space: nowrap;
overflow: hidden;
}
I don't think we need to even use the text-indent hack on the carets, but I'll add this as a mixin and check that out.
Ended up removing the text-indent in the carets so we don't need this anymore, but I'll add it to the mixins for those who might need it.
I know this was already added to v2.0.2 - but HTML5's version seems to work a bit better IMHO https://github.com/h5bp/html5-boilerplate/commit/aa0396eae757c9e03dda4e463fb0d4db5a5f82d7 Maybe something to look at for the future. Thanks!
Ah, I was just about to mention this and @zslabs has beaten me to it. I think @scottkellum (the originator of this new IR technique) is also in agreement with the modified IR technique that @necolas introduced to @h5bp.
@nimbupani Actually I am still on the fence for using it myself as a heavy user of ems. Bootstrap is pixel/percent based so the font: 0/0 a method is better in those situations.
Just an FYI: Compass users revolted when I changed the default hide-text to the font: 0/0 approach because of the issues with em-based margins. But I really like the font: 0/0 approach because you can use it to hide inline content for display but it will still be consumed by screen readers. So I am using text-indent: 110% for the default hide-text mixin in compass (110% seems to keep inline-block elements from breaking). And I added a squish-text mixin for when the font: 0/0 approach is needed. http://compass-style.org/reference/compass/typography/text/replacement/
@chriseppstein ++ thanks Chris.
I am using text-indent: 110% for the default hide-text mixin in compass (110% seems to keep inline-block elements from breaking)
Nope. That doesn't prevent it seriously breaking for inline-block elements in IE6/7.
Another problem to be aware of with the positive text-indent method is that the text is revealed in several screenreaders when focus is placed on the IR-ed element - https://github.com/h5bp/html5-boilerplate/commit/aa0396eae757c9e03dda4e463fb0d4db5a5f82d7#commitcomment-1052728
IMO, the negative text-indent is the way to go if you want to preserve em use. It doesn't have the most significant drawbacks of the positive text-indent method, and only seems to be problematic in 1st gen ipads when the element is also being animated.
The NIR method is the way to go if you're IE8+ - appears to have none of the drawbacks and even works with images off.
Is inline-block really something we care about on IE<=7 as inline-block is already broken on those browsers?
inline-block is already broken on those browsers
*display:inline; *zoom:1 - IE6/7 inline-block hack.
I do the same except put the display inline and zoom 1 loaded via a class with conditional statements (the HTML5 Boilerplate way) to keep the CSS valid.
Negative text-indent would also fix this background positioning problem in IE7: http://jsfiddle.net/salantsa/3DYd2/
@antsa I noticed this in one of my text cases too - http://jsfiddle.net/necolas/drHaR/2/ - IMO the positive text-indent method is too buggy.
So. It might seem ugly, but you can also just include a tiny 1px x 1px image (always the same image so it isn't downloaded multiple times... and put the alt text on that image. It doesn't cause display bugs or perf issues.
I'm also not convinced that the -9999px method really causes perf issues. I was unable to measure any difference between the two.