csstools / postcss-nesting

Nest style rules inside each other

Home Page:https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nesting

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can i nest a tag inside a class?

simonh1000 opened this issue · comments

I'm asking because the docs don't include an example like this, which is influenced by my scss experience.

.icon-container {
    width: 202px;
    img {
        max-width: 80%;
    }
}

what I'm seeing is
image

Hi @simonh1000,

Have you tried the following?

.icon-container {
    width: 202px;
    & img {
        max-width: 80%;
    }
}

This would be equivalent to:

.icon-container {
    width: 202px;
}

.icon-container img {
    max-width: 80%;
}

ah, thanks for the tip - I was using what I knew to work from SCSS