Description
CSSOM says for top
, right
, bottom
and left
:
If the property applies to a positioned element and the resolved value of the display property is not
none
or contents, and the property is not over-constrained, then the resolved value is the used value. Otherwise the resolved value is the computed value.
Therefore, if I use
element.style.cssText = "position: relative; left: 1%; right: 2%;";
getComputedStyle(element).right;
since relative positioning doesn't stretch boxes, there is over-constrainment, so I should get the computed value.
So what's the computed value of a percentage? https://drafts.csswg.org/css-position-3/#box-offsets-trbl says
For
position: relative
, see Relative positioning.
[...] Otherwise: [...] if specified as a<percentage>
, the specified value[...].
Relative positioning doesn't mention percentages, so it seems it should be the specified value according to "otherwise". But that's not the case in Firefox and Blink, which return the absolute length instead.
WebKit returns the used value when there is over-contraintment and I want to implement the proper behavior, which is not clear.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status