-
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
Nesting :extend inside a media query #1922
Comments
Can you clean up that snippet and explain where Also, is there a reason you have to extend from within the media query? Because if you're trying to get Btw, |
The item only displays at that screens size so thats why I nested everything for the element in media query. .gotham-narrow-bold is extending font-family, font-style, and font-weight and its located in a typography.less file. |
@reubeningber Okay, so if I'm getting it right, you're situation's something like this. .font-family-style-weight {
/* font stuff */
}
.gotham-narrow-bold {
&:extend(.font-family-style-weight);
}
@media (min-width: 768px) {
.subscribe-options li a {
&:extend(.gotham-narrow-bold);
}
} As far as a solution, it seems to me you have two options. Mixin Optioninput.font-family-style-weight {
/* font stuff */
}
.gotham-narrow-bold {
&:extend(.font-family-style-weight);
}
.gotham-narrow-bold-mixin() {
.font-family-style-weight(); // mixin instead of extending
.gotham-narrow-bold; // copies everything else declared in `.gotham-narrow-bold`
}
/* Implementation */
@media (min-width: 768px) {
.subscribe-options li a {
//&:extend(.gotham-narrow-bold);
.gotham-narrow-bold-mixin(); // use mixin instead
}
} output.font-family-style-weight,
.gotham-narrow-bold {
/* font stuff */
}
/* Implementation */
@media (min-width: 768px) {
.subscribe-options li a {
/* font stuff */
}
} The alternative is to structure your stylesheet differently. There's nothing wrong with, for example, something like this: Extend/Adjust CSS Optioninput.font-family-style-weight {
/* font stuff */
}
.gotham-narrow-bold {
&:extend(.font-family-style-weight);
}
.gotham-narrow-bold-mixin() {
.font-family-style-weight(); // mixin instead of extending
.gotham-narrow-bold; // copies everything else declared in `.gotham-narrow-bold`
}
/* Implementation */
.subscribe-options li a {
&:extend(.gotham-narrow-bold);
/* hidden somehow */
}
@media (min-width: 768px) {
.subscribe-options li a {
/* undo "hidden somehow" */
}
} output.font-family-style-weight,
.gotham-narrow-bold,
.subscribe-options li a {
/* font stuff */
}
/* Implementation */
.subscribe-options li a {
/* hidden somehow */
}
@media (min-width: 768px) {
.subscribe-options li a {
/* undo "hidden somehow" */
}
} For discussion about the good and bad about the current behavior, you can check out the issues @seven-phases-max referenced. Hope that helps. |
Closing as expected behaviour (http://lesscss.org/features/#extend-feature-scoping-extend-inside-media). |
According to the language design discussion on #1165, calling an extend from within a @media query should extend selectors outside of that media query. E.g. (slightly modified) from that thread
Should compile to:
@seven-phases-max - I see from the documentation that it wasn't implemented that way, but I don't see anything from those threads as to why it was implemented differently. (So the documentation may not be "proof" of what should happen; it may be faithful documentation of a bug.) The consensus from #1165 was that external (outside a @media block) matching selectors should get copied from outside to within the @media block. Not sure if this is too late to fix or what the implications might be, but it appears this was missed in the original implementation. I'll open unless there's a later issue that tracks / explains the discrepancy. |
@matthew-dean OK, but we already have an open issue for this "new" feature: #2095. |
@seven-phases-max Ah, ok. That's what I was looking for. Thanks, closing. |
When using the extend functionality nested inside a media query less fails to extend the css that you call. The other styles including the
.font-size-rems()
works inside the query.Code snippet below:
The text was updated successfully, but these errors were encountered: