-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Media-query can now be a variable #643
Conversation
+1 Thats a fantastic idea. Can't wait to use this. |
+1 |
+1 |
@sirlantis is on a roll. |
I like this |
Merged. |
This is an insanely great idea, managing one of the trickiest things now. Is this in 1.2.2? |
Hi guys, Is there any way of conditionally including responsive code easily. Essentially I would like a variable in my root less file like so: @isResponsive: false; and for that to decide if at compilation time that the stylesheet for 900px+ is included for all browsers when is responsive is false and when @isResponsive is true we use the standard media queries for this. Any ideas on how to accomplish this would help use to future proof our sites immensely. Thanks, Andy. |
@aphillipo - I am trying to get a solution to that problem. The only real way to accomplish this would be fore LESS to implement a SASS-like
|
Just wanted to reference Issue #965, where we are trying to come up with a SASS-like |
@aphillipo @DesignByOnyx there's a way you can achieve what you're looking for by using LESS string interpolation to change a media query into a media type (which is supported down to IE6). For example: |
@himedlooff - great solution. You should point out that all "min-width" media query variables should be overwritten for the IE build. For example: /* variables.less */
@mobileUp: "only screen and (min-width: 320px)";
@mobileOnly: "only screen and (min-width: 320px) and (max-width: 480px)";
@tabletUp: "only screen and (min-width: 600px)";
@tabletOnly: "only screen and (min-width: 600px) and (max-width: 960px)";
/* IE-variable-overrides.less - used only for the IE build */
@mobileUp: "screen";
@tabletUp: "screen";
/* page-styles.less */
@media @mobileUp {
...
} |
@DesignByOnyx thanks, great point! |
As a follow-up to #634 I found it really annoying to have the same, repetitive media-queries flying around in my document. Normally I design for 2-4 resolutions/viewports:
Ways to handle that:
@media screen and max-width(600px) { ...
@media screen and max-width(@tabletWidth) { ...
@media @tablet { ...
This Pull-Requests allows the latter option. I wanted to avoid pollution of the variable-definition-parser, so you have to define
@tablet
like this:You can still use string-interpolation if you have
600px
defined somewhere else and don't want to hard-wire it into that string.