3 ms·
I wonder if a javascript/jquery helper could be used as a fill for now? You could set up size points for an Element like this (mobile first approach) : $(".te
by wubbfindel 14y ago
I wonder if a javascript/jquery helper could be used as a fill for now?
You could set up size points for an Element like this (mobile first approach) :
$(".testimonials").when-min-width(400px, "medium").when-min-width(800px, "large");
Then you're CSS could look like this :
.testimonials{
// do basic stuff, and small display stuff
}
.testimonials.medium{
// do medium display stuff
}
.testimonials.large{
// do large display stuff
}
Hmm. Maybe I'll build it.
- nkozyra 14y agoOf course you could, but in addition to mobile devices, the point of media queries is to handle anything that might make a standard HTTP request. This includes televisions, older phones, gaming consoles, you name it. Javascript is relatively unreliable on many of those devices; what's worse, you don't want to force a jquery call just to do something that's actively supported by CSS3.
- wubbfindel 14y agoAll good points. But I did think if them before posting. "Javascript is relatively unreliable on many of those devices" AFAIK it's reasonable to argue that just as Javscript can be unreliable, even non-existent, on many devices, so can CSS media queries. I think it's fair to say that media queries are still a "modern" browser feature. http://caniuse.com/css-mediaqueries http://caniuse.com/css-mediaqueries "what's worse, you don't want to force a jquery call just to do..." Agreed - jquery is too large just for this. That's why I said "javascript/jquery". The jquery like syntax used was for simplicity. But in truth any simple selector engine would do the job. Sizzle for example, or even a home-grown one. "...something that's actively supported by CSS3" But that's the point OP was making isn't it? AFAIK, CSS3 @media queries do not support element level querying.
- talmand 14y agoPlus if the desired result is supported in CSS3 then you can use javascript to just trigger the change via CSS instead of performing the task through the script. An obvious example of this is transitions. If you have CSS3 transitions you can trigger them with a class name change instead of using jquery's animation code. When you can do that you don't need jquery or other library at all. Unless you have simply awful HTML that requires an advanced selector engine, such as Sizzle as you state. But as you point out, if the devices listed have unreliable support of javascript then chances are it has unreliable support of CSS3. I don't understand the argument against building a shim as a proof of concept though. What's wrong with building the example to see if it becomes popular in traditional uses of CSS before pushing it as a standard? Don't bother since it might not work on TVs because of lack of proper javascript support?