Skip to content

I want to pin evaluation of a CSS custom property to the element it's defined on #236

Closed
@aarongustafson

Description

@aarongustafson

As an example, if I need to know the width of a container element to calculate the width of a deeply nested element:

.container {
  --container-width: 100%; 
}

.container__deeply-nested-element {
  // what I need is the actual container width to be able to correctly
  // calculate the desired width of the nested element...
  // but 100% is evaluated here to the element's parent :(
  width: calc(var(--container-width, 0) / 3); 
}

Metadata

Metadata

Assignees

Labels

CSSno-activitywantIncoming requests from the community

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions