Skip to content

css expression inheritance #2749

Open
Open
@Wes0617

Description

@Wes0617

Hi w3c people! I have a proposal about calc(), var() and similar functions.

I'd like to be able to inherit the expression itself rather than the computed-once value they contain.

For example if I write calc(1em + 20px) I expect to get the current font-size added of 20px, rather than the font-size computed at the time of the very first evaluation of the calc() expression.
A simple example could be the following:

div{
    --foo: 10px;
    --border: calc(var(--foo) - 5px); /* --border must always be --foo - 5px */
}


div > p{
    --foo: 100px;
    /* --border: inherit; /* no effect */
    /* --border: var(--border); /* no effect */
    border: var(--border) red solid; /* expecting 95px red solid - but got 5px red solid */
}

http://jsfiddle.net/pd3zeg9v/

What do you think? Or maybe this is already possible and I don't know how?
Thank you in advance.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions