HTML
<canvas id="canvas" width="800" height="600">
</canvas>
<div class="content"></div>
CSS
div.content {
:root {
--xPos: canvas[id="canvas"].width/2;
}
position: absolute;
left: var(--xPos);
bottom: 100px;
}
I tried using an attribute selector to get the canvas.id.width value so I can set the left margin edge property for div.content to the canvas' width/2. However, it seems like attribute selectors are used to style elements with specific attributes/values rather than to return an attribute value.
is there a way(function/method) to use a HTML attribute value as a property value within CSS? and then use it in expressions like in JS such as attrValue*2 or attrValue/2.
Thanks.