You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Variables not being replaced in media queries declaration #122
This is still the issue to me. Has there been any action on this?
Both variables and @import rules within @media queries are not converted and are just output as they are not converted at all. Let's asume I have core.less file that has some variables and CSS in it. Then I have another .less file, that dispatches different stylesheets based on @media queries. So to serve core.less to a device I do the following:
@media only screen and (min-device-width : 769px) {
@import "core";
}
In resulting CSS it turns into
@media only screen and (min-device-width : 769px) {
}
If I want to work around this and instead of importing core.less will import compiled core.css file like:
@media only screen and (min-device-width : 769px) {
@import "core.css";
}
it compiles without any change to:
@media only screen and (min-device-width : 769px) {
@import "core.css";
}
With regard to everything I've seen from the draft CSS 3 specs, @import statements are not allowed within @media directives. This, however, is allowed by the spec:
My issue is imports inside the media blocks, the same as mishunov and matthewdl. I guess that's a different issue than the variables replacements? but it seems related to this issue as other's talked about it here..or is there another issue opened on that?
Maybe it will be easier to understand what I'd like with this workaround that I use now:
`<link href="@Url.Content("~/public/less/styles.978.gs.less")" rel="stylesheet" type="text/css" media="only screen and (min-width: 768px) and (max-width: 1139px)"/>
`
I have different grids that are computed off different values for variables and I use those grids for different resolutions. The grids are based on Semantic.gs where I have a couple of mixins like .column(number-of-columns).
Strangely though, I don't have strictMath set to true. Even when I set it to false I was still getting it.
My config:
{env: "production",// or "production"async: false,// load imports asyncfileAsync: false,// load imports async when in a page under// a file protocolpoll: 1000,// when in watch mode, time in ms between pollsfunctions: {},// user functions, keyed by namedumpLineNumbers: "comments",// or "mediaQuery" or "all"relativeUrls: false,strictMath: false// whether to adjust url's to be relative// if false, url's are already relative to the// entry less file//rootpath: ":/a.com/"// a path to add on to the start of every url//resource}
Activity
dylan commentedon Jan 19, 2011
I am having this problem as well.
mishunov commentedon Apr 2, 2011
This is still the issue to me. Has there been any action on this?
Both variables and @import rules within @media queries are not converted and are just output as they are not converted at all. Let's asume I have core.less file that has some variables and CSS in it. Then I have another .less file, that dispatches different stylesheets based on @media queries. So to serve core.less to a device I do the following:
In resulting CSS it turns into
If I want to work around this and instead of importing core.less will import compiled core.css file like:
it compiles without any change to:
vincentbernat commentedon May 23, 2011
I also would like to get variables replaced inside media query. Something like this :
The CSS generated from this still contains @page-width instead of its value.
maranomynet commentedon Aug 12, 2011
+1 for this issue!
davetayls commentedon Aug 28, 2011
Is this being looked at? I would like to use it in the same way as @vincentbernat
PaulAdamDavis commentedon Sep 5, 2011
+1 on this too. I want to use it the same way as @mishunov
dfreerksen commentedon Sep 7, 2011
The only solutions I have found to this is to do something like this:
.max-width-768() {
body {
background-color: #FF00FF;
}
}
@import "768.less";
@media (max-width: 768px) {
.max-width-768();
}
The other option I have found is:
@import "768.less";
@media (max-width: 768px) {
body {
background-color: #FF00FF;
}
}
jayf commentedon Oct 5, 2011
Likewise, I'd would like to use it in the same way as @vincentbernat, e.g.,
I see in parser.js where it grabs the media rule, but I'm still too new to the code to see the exact changes needed...
ttfkam commentedon Oct 5, 2011
With regard to everything I've seen from the draft CSS 3 specs, @import statements are not allowed within @media directives. This, however, is allowed by the spec:
I haven't tried this with Less, but if there is going to be compatibility with CSS, perhaps this should be the target instead of nesting import statements. http://www.w3.org/TR/css3-mediaqueries/
maranomynet commentedon Oct 6, 2011
@importing LESS files should be possible inside@mediablocks IMO, even though CSS @import (linking) is invalid.However, the original issue being reported is that LESS currently doesn't allow variables or other such niceties following
@mediaand@importloa commentedon Nov 21, 2011
+1 Need same thing as @vincentbernat
matthew-dean commentedon Nov 22, 2011
Ah, looks like I stumbled upon the same bug. My statement:
@import "desktop/nav";This imports perfectly well OUTSIDE a media query, but vanishes with no error inside a media query.
razialx commentedon Dec 1, 2011
I have a patch for this I am getting ready to submit. Haven't looked at the importing, just the variable replacement.
razialx commentedon Dec 1, 2011
So, I messed up my pull request apparently. The patch for this is in this request: #481
Should have been in its own. It is the second commit. Can find the original commit on my branch here:
razialx@1f97c27
Issue less#122: Updated directive class to support parsing variables …
36 remaining items
brgrz commentedon Feb 11, 2013
My issue is imports inside the media blocks, the same as mishunov and matthewdl. I guess that's a different issue than the variables replacements? but it seems related to this issue as other's talked about it here..or is there another issue opened on that?
brgrz commentedon Feb 11, 2013
Maybe it will be easier to understand what I'd like with this workaround that I use now:
`<link href="@Url.Content("~/public/less/styles.978.gs.less")" rel="stylesheet" type="text/css" media="only screen and (min-width: 768px) and (max-width: 1139px)"/>
`I have different grids that are computed off different values for variables and I use those grids for different resolutions. The grids are based on Semantic.gs where I have a couple of mixins like .column(number-of-columns).
kamranayub commentedon Feb 11, 2013
This doesn't work already @mhrovatic?
Because we're doing this in our projects already.
brgrz commentedon Feb 11, 2013
What exactly are you doing? please post a sample code
kamranayub commentedon Feb 11, 2013
We're doing more than you're asking ;)
No issues here using Mindscape.
brgrz commentedon Feb 11, 2013
Is the "modules/_header" an uncompiled LESS file that includes variable declarations?
For instance can you do this
'@import "978grid_vars"; // defines and initializes some variables
@import "grid"; // uses those variables'
This doesn't seem to work for me with dotless, says variable is undefined.
lukeapage commentedon Feb 12, 2013
if it is dotless you are using, raise the issue with https://github.com/dotless/dotless - it is a port, it doesn't directly use less.js
lukeapage commentedon Feb 16, 2013
this is implemented in master
adam-lynch commentedon Dec 15, 2013
This is a frustrating one :/. Really limits what I want to do with variables but I need to compile on the fly in the browser too.
Wanted to do stuff like:
Or even:
Soviut commentedon Dec 15, 2013
@adam-lynch Both examples should work fine by now. What version of LESS are you using?
adam-lynch commentedon Dec 15, 2013
@Soviut 1.5.0
Soviut commentedon Dec 15, 2013
If you have the
strictMathoption turned on, you'll need to wrap your math operations in parenthesis(@feedMaxWidth + @gutter_base)adam-lynch commentedon Dec 15, 2013
@Soviut, parenthesis sorted it.
Strangely though, I don't have
strictMathset totrue. Even when I set it tofalseI was still getting it.My config:
seven-phases-max commentedon Dec 15, 2013
The trick is that math operations are not evaluated without parenthesis inside media feature expressions regardless of strictMath settings. E.g.:
result (strictMath: on):
result (strictMath: off):