W3C home > Mailing lists > Public > public-css-archive@w3.org > November 2017

[csswg-drafts] [css-variables] define custom property based on parent's (inherited) value

From: Ilya Myasin via GitHub <sysbot+gh@w3.org>
Date: Wed, 08 Nov 2017 22:36:41 +0000
To: public-css-archive@w3.org
Message-ID: <issues.opened-272375129-1510180599-sysbot+gh@w3.org>
dubrowsky has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-variables] define custom property based on parent's (inherited) value ==
According to the [Resolving Dependency Cycles](https://drafts.csswg.org/css-variables/#cycles) section of the spec it's not possible to use `var(--property)` while defining the `--property` itself.

Here's an illustration of the problem I'd like to solve:

    .table {
        width: 60vw;
        --width: 60vw;
    }

    .column {
        width: 25%;
       // should be (60vw / 4) = 15vw
        --width: calc( var(--width) / 4);
    }
    
    .something-inside-the-column {
         // should be (60vw / 4) * 0.1 = 6vw
         font-size: calc( var(--width) * 0.1 ); 
    }

So I'd like to use the inherited value if the own is not yet defined. If this behavior is hard to implement, maybe the specification can introduce another function to use inherited values explicitly, something like this:

        --width: calc( inherited-var(--width) * 0.1 );

The solution suggested [here](https://github.com/w3c/csswg-drafts/issues/876#issuecomment-271660651) (just use two different props) is not the answer, because I want my components to be "context-agnostic". Please tell me if my case is not clear enough, I'll try to provide some better example then. Thank you!

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/1962 using your GitHub account
Received on Wednesday, 8 November 2017 22:36:46 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 November 2017 22:36:47 UTC