-
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
Ability to prepend class to the selector #1002
Comments
use
to prepend. |
Read the docs because the & operator allows a lot of other useful functionality. Specifically things like applying :hover selectors: .comment {
background: white;
&:hover { background: cornflowerblue; }
} As well as relating elements that have multiple classes. For example class="comment important". .comment {
background: white;
&.important { background: cornflowerblue; }
} When something feels that deeply painful, assume someone has already solved that problem and seek out the solution. |
I was using & for all pseudo selectors/classes, but somehow it never came to my mind I can use it prepend class'es :) |
not to mention
:) |
This one is also interesting discovery, yet when this is actually useful? :) I have one more great idea (at least I hope so): Some sort of mixin's and & version for cases when context determined by screen width. Instead of adding .home, wrap it in the @media. e.g.
In ideal case LESS could also group all identical @media max-size=100{} blocks into single one at top/bottom of the css file to save space by not repeating @media rules. Or this is also already possible? :) |
I've already proposed grouping @media rules here #950 It seems the general consensus it that doing it automatically could break certain existing rules, but adding a @media-group syntax might help. |
It works but doesn't group. There is a feature request to group.. |
In many cases it makes sense to have elements styled based on context.
For example:
We have standard HTML widget
.... used in both home page and featured posts pages. Yet home page has , featured (technique commonly used in WordPress and similar CMS'es)All else being equal, we want our article in featured posts page to have bigger H1 text.
At the moment we would have to put custom new css rule away from the main H1 definition like
This makes our code nightmare to manage, as totaly related rules are separated :/
However, if we just could have modifier to prepend css selectors to the stack like
to compile to
This would be awesome :)
The text was updated successfully, but these errors were encountered: