Description
title: I want to pin evaluation of a CSS custom property to the element it's defined on
date: 2020-12-04T19:35:43.617Z
submitter: PRIVATE
number: 5fca8f8fcb050301104f7a6a
tags: [ ]
discussion: https://github.com/WebWeWant/webwewant.fyi/discussions/
status: [ discussing || in-progress || complete ]
related:
- title:
url:
type: [ article || explainer || draft || spec || note || discussion ]
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);
}
If posted, this will appear at https://webwewant.fyi/wants/5fca8f8fcb050301104f7a6a/
Activity