Skip to content

@media queries should behave like nested rules #152

@tylertate

Description

@tylertate

I've been working closely with @media queries for a new version of the 1KB CSS Grid that will be written in LESS.js, but I have noticed two crucial inconsistencies in how @media queries are currently being handled:

You shouldn't need to define a selector within a media query, but should be able to specify CSS attributes directly. For instance:

header {
    width: 50%;

    @media (max-width: 720px) {
        width: 100%;
    }
}

Secondly, @media queries in LESS.js should be aware of their position within other nested rules. For example:

article {
    header {
        width: 50%;

        @media (max-width: 720px) {
            &:hover {
                width: 100%;
            }
        }
    }
}

Should result in:

article header:hover { width: 100%; }

But unfortunately, it currently results in:

header:hover { width: 100%; }

I am more than happy to be a champion for @media query support in LESS, so please let me know if there's anything else I can do to help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions