-
Notifications
You must be signed in to change notification settings - Fork 12.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reassess IR techniques #1149
Comments
I've been playing around with another IR technique. It's a hybrid approach; not sure if it's been thought of before. Below is its simplest form (without any extra cruft that you might need for .ir {
overflow: hidden;
*text-indent: -999em;
}
.ir:before {
content: "";
display: block;
width: 0;
height: 100%;
} The pseudo-element forces the content downwards without covering up the background of the element. Then the overflow is hidden. For IE 6/7, we fall back to the From what I've learnt so far... Pros:
Cons:
I could do with some people to help test this out a bit more (across different browsers, inc. mobile) and find any additional problems. Also, opinions about this. cc @h5bp/html5-boilerplate @scottkellum @brendanf @chriseppstein @scottjehl |
Looks identical in Google Chrome Canary (Windows), Android 4.1.1 browser, and Chrome for Android 4.x |
Why do you think it's better than this one?
I prefer to avoid pseudo-elements for tricks (just for visual things), it's a fact that they are very slow when browsers renders them and parse the selector. |
Because that method is pretty buggy
Where is the data to back that up? Pseudo-elements are already used everywhere that the clearfix hack is used. And rendering a pseudo-element isn't going to be as slow as loading an image. It seems like an non-issue. |
There is no link to show you this thing (sorry), but I had time to test them with Chrome's CSS profiler tool creating a list of a lot of elements with a before (doing a lot of visual things) and another HTML replacing before with span nodes with the same behavior. Chrome's profiler tool said both ::after and ::before pseudo-elements are 5-10% slower (while parsing) than a normal HTML node. Of course I don't know why but maybe you can give it a try. Anyway, I have test it just in Chrome so it could differ in other browsers. So, having a trick without pseudo-element it's faster than with it, more if we use it in a large website with a lot of IRs. One more thing, why the way I said is buggy, I never had problems with it since I use it. |
I'm not going to lose any sleep over 2ms + 10%.
I did a bunch of tests of it last time we looked at IR in HTML5 Boilerplate, it has plenty of issues and edge-case problems that make it unsuitable to roll into this project: aa0396e |
Another con (probably a small one):
|
@mkantor I thought about that too, but I think you likely won't need it for IR elements, or can simply use ::after. Personally, I'm favoring the font-crush, unless someone can authoritatively tell me that it will kill SEO. For the time being, losing IE7 support again is too big. |
IE 6/7 are both supported by this technique as it includes the same old negative text-indent method for them. The font-crushing method actually leaves a bit of residue in IE6/7. |
@necolas Ah, I meant in the case of inline-block'd elements, which was major thorn in my side until your excellent font-crush solution. |
Yeah, that kinda sucks if you need IE 6/7 support with inline blocks. Hmmm |
Not sure if this is what you're looking for. The code above doesn't hide text for me, but this does:
Here's the Fiddle: http://jsfiddle.net/maxw3st/bLfUK/ |
I know this isn't for mobile, but FYI.. using negative ems to hide text doesn't work on Android ICS. I had to use negative px values for it to actually hide, e.g. -999px (Droid Razr ICS). |
How does it not hide text? Did you open the fiddle? Your example isn't much different to just using negative text-indent. It has pretty much all the same problems.
It is for mobile. But the negative text-indent is only for IE 6/7 |
That performance is importante in large websites, but you're right, it's nothing in real cases. Thank you necolas! |
I've used this for text replacement (which finally is the same) and the behavior is perfect:
|
@necolas hey man, do you think this is bug or am I using
|
Use a |
Yup, I knew there is something I was missing here... :) Thanks! |
@davidmurdoch Hmmm it seems this is not working in firefox? O_O |
You havent set any dimensions on the element that is receiving IR |
Look again in css field: http://jsfiddle.net/musicisair/8BSL3/1/ a, button {
display: block;
width: 128px;
height: 128px;
background-image: url('http://2.bp.blogspot.com/_6rROSHI_zZ4/SfY4yPxlHFI/AAAAAAAABpY/0iPyrZOreHc/S220/cat_avatar_0065_www.free-avatars.com.jpg');
} |
Oh yeah, I see. You'll have to use an element within |
Various issues need to be considered and the pros/cons of techniques reassessed:
#1108
#1125
#1144
The text was updated successfully, but these errors were encountered: