postcss / postcss-custom-properties

Use Custom Properties in CSS
https://postcss.github.io/postcss-custom-properties
MIT License
596 stars 77 forks source link

Is this not supported yet? #111

Closed sty1iss closed 6 years ago

sty1iss commented 6 years ago

I can't search this case, because my english. result was not like my thought.

before

:root {
    --head-color: red;
}

h2 {
    --head-color: green;
}

h1,
h2 {
    color: var(--head-color);
}

@media (max-width: 1000px) {
    :root {
        --head-color: blue;
    }

    h2 {
        --head-color: yellow;
    }
}

after

:root {
    --head-color: red;
}

h2 {
    --head-color: green;
}

h1,
h2 {
    color: red;
    color: var(--head-color);
}

@media (max-width: 1000px) {
    :root {
        --head-color: blue;
    }

    h2 {
        --head-color: yellow;
    }
}

as i want

:root {
    --head-color: red;
}

h2 {
    --head-color: green;
}

h1,
h2 {
    color:red;
    color: var(--head-color);
}

h2 {
    color:blue;
    color: var(--head-color);
}

@media (max-width: 1000px) {
    :root {
        --head-color: blue;
    }

    h2 {
        --head-color: yellow;
    }

    h1 {
        color:blue;
        color: var(--head-color);
    }

    h2 {
        color:yellow;
        color: var(--head-color);
    }
}
sty1iss commented 6 years ago

I Found postcss-css-variables for this case. anyway thanks for learned difference.