-
Notifications
You must be signed in to change notification settings - Fork 0
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
Other MQ syntax? Also, is grunt-recess required? #1
Comments
This is only a method, there's no custom parsing I'm doing to achieve this. I wanted to point out that you can use LESS to switch media queries to media types by using LESS's built-in string interpolation method. The following is straight from http://lesscss.org/
@base-url: "http://assets.fnord.com";
background-image: url("@{base-url}/images/bg.png"); RE: Grunt recess it's only there to compile LESS. RE: Other media query formats great question! I don't know but I'll run some tests. |
Ah, this is cool! Thanks for updating the README! Your new examples and docs really made it much more clear to me. I'm looking forward to testing this. I'll let you know the results of my tests (like I said before, I'm also wanting to use this technique to attain a desktop print style sheet). I really like this technique as it's pretty straight forward. It's one of those things that when you point it out, I'm like "duh, why didn't I think of that!". 👍 Lol, thanks!!!! I'll be back with my results. |
So, good news! First, ignore my question about the retina display media query ... Old IEs and/or printers don't need that high resolution stuff, so it's a good thing that those devices/browsers ignore said media query(s). 👍 Second, I've done some quick testing (I won't have time to do more thorough testing until later this week) and (thanks to your inspiration and code samples) I've been getting some good results! Without even using LESS, I wanted to test some combinations of MQs to see how this would work (without spending a lot of time setting up a grunt LESS project). Attempt 1I wanted to see how the below would behave across old IEs and printers: /* MOBILE */
/* ... styles here ... */
@media {
/* TABLET */
/* ... styles here ... */
}
@media {
/* SMALL DESKTOP */
/* ... styles here ... */
}
@media {
/* DESKTOP */
/* ... styles here ... */
} As you can see, I've opted to not have any arguments afer my THE GOOD:
THE BAD:
Related to IE8 not behaving: Media query syntax when a separate style sheet is included (alternative link) ... The above thread makes a reference to this post: Techniques For Gracefully Degrading Media Queries ... on the above page is a section title "Technique 3: Circumvent Media Query Conditions"; the author contends that
It's amazing that IE8 fails and IE6/7 work when using that technique. Too bad too, because that would have been a pretty sweet, non-LESS, fix for graceful degradation of MQs in older IEs. I digress ... Attempt 2/* ... MOBILE ... */
/* ... styles here ... */
@media all {
/* TABLET */
/* ... styles here ... */
}
@media all {
/* SMALL DESKTOP */
/* ... styles here ... */
}
@media all {
/* DESKTOP */
/* ... styles here ... */
} SUCCESS!From what I've tested, like you've already pointed out, old IEs, and my printer, are getting the "desktop" styles (plus cascade). Now, like you have pointed out already, I just need to do: <!--[if lt IE 9]> <link rel="stylesheet" href="styles/styles-desktop.css"> <![endif]-->
<!--[if gt IE 8]><!--> <link rel="stylesheet" href="styles/styles.css"> <!--<![endif]--> ... and for print: <link rel="stylesheet" media="print" href="/styles-desktop.css"> Note: I don't typically have special vars for old IEs, so I'd probably load Awesome! 👯 I'm kinda stoked that I don't need to switch to SASS just so I can use Btw, here's my test code if you (or others) want to play: Sorry, no LESS. I just wanted to quickly test changes to my Thanks again for the inspiration/tips/help! It's much appreicated!!!! |
@mhulse wow thanks for documenting your research, it's great to see that Can you update that link to the Media query syntax when a separate style sheet is included article? It's linking to this issue page accidentally. I'm pretty psyched about this approach as well. I was using respond.js and ran into a "flash of small screen layout" issue before the large screen layout kicked in. This approach seems to be a better alternative, thanks again for the input! |
@mhulse also, out of curiosity how do you usually compile LESS? I'm using grunt because I can have it compile two different stylesheets for me automatically. You don't need it though you can compile as normal with any other compiler. |
Awesome! I also just tested Demo page here: So, at least for the simple tests that I've done, unless I've missed something obvious, both For me, I'll be using As I mentioned earlier, when using a "mobile-first" approach and Alternatively, using Anyway, I'm hopeful that your solution will work on my latest project (based on my test page results, I'm hopeful). FYI, I'm researching now if there are any corner cases that I have not thought of ... I'll be back if I learn anything new.
Ooops! Updated link. Sorry about that. There's really not much there. Just a thread I started on CSS-D a few months back. I mostly just wanted to point out some of my other research/conversations on print topic.
OMG, yah. You know, respond.js is great for small sites. I was also using that until I realized how much of a headache it can be on a large site with multiple CSS asset servers/cdns. The whole cross-domain setup is a pain in the ass. I'm ready to feed OLD IEs desktop styles. I'm using LESS and I don't want to switch to SASS (just so I can use
Oh, I'm a HUGE Grunt.js fan! I've been using the gurnt-contrib-less task. To prove to you that I'm a grunt man, I've setup a boilerplate repo that I use for my Grunt repos (also, this was setup to help get my co-workers up-to-speed with a Grunt workflow): https://github.com/registerguard/grunt-boiler That's setup currently to be more of a JS plugin workflow; I'll probably be adding a boilerplate setup for CSS/LESS stuff in the coming weeks. Anyway, thanks for the awesome conversation and code inspiration! I'll be back with updates! :) |
So, just to satisfy my own curiosity, I pinged a large group of CSS gurus found on the CSS-d list:
Conclusion: We're good to go! Well, you probably already knew that ... I just am the type of person to beat a dead horse. 🐴 Relevant information: MSDN: CSS Compatibility in Internet Explorer ... where:
From there, I followed the On that page, the list of supported "media types" are:
Additionally, to drive home the point, Philippe states:
... which, for that last part, I think explains why IE was having troubles with So yah! I'm really stoked now. This actually seems like a pretty awesome alternative to using SASS' Thanks! |
@mhulse thanks for all of this! I've got a project going live with this approach really soon and will let you know what how it turns out. |
Awesome! I'm looking forward to hearing about your results. I hope to impliment your solution as well in the (hopefully) near future. 👍 Thanks again Mike! |
Hi,
Thanks for sharing code! Seems like a good solution. I'd prefer to stick with less vs. switch to SASS for its
@content
feature.Couple of quick questions:
What happens if my MQ is:
... or something like this (for retina):
I find that in my CSS I'm needing the flexibilty of doing the above. Would your code be able to parse/handle some of the more advanced MQ statements?
Also, is grunt-recess required?
Thanks!!!! :)
The text was updated successfully, but these errors were encountered: