Reputation: 6912
According to MDN:
If
from
/0%
orto
/100%
is not specified, the browser starts or finishes the animation using the computed values of all attributes.
In the following example, the height
property computed value is 0px
:
div#parent {
width: 100px;
height: 100px;
outline: 1px solid teal;
}
div#child {
background: tan;
animation: lengthen 2s infinite;
}
@keyframes lengthen {
to {
height: 100px;
}
}
<div id="parent">
<div id="child"></div>
</div>
But the browser uses height: auto;
, which is the element specified value, and that's why the animation doesn't work.
Here's something similar on the spec:
If a
0%
orfrom
keyframe is not specified, then the user agent constructs a0%
keyframe using the computed values of the properties being animated. If a100%
orto
keyframe is not specified, then the user agent constructs a100%
keyframe using the computed values of the properties being animated.
But if the browser actually added from {height: 0px;}
, which is the computed value, then the animation would work properly. Isn't it more accurate to use specified value instead of computed value in the above-mentioned documentation?
Upvotes: 0
Views: 363
Reputation: 1875
MDN is correct, the initial value of height is actually auto, the "computed" value that browsers show is the value that special keywords and initial values translate to.
Upvotes: 0
Reputation: 172
MDN has right, because the computed value of height: auto is height: auto. 0px is the used value.
According to MDN again:
However, for some properties (those where percentages are relative to something that may require layout to determine, such as width, margin-right, text-indent, and top), percentage specified values turn into percentage computed values.
Upvotes: 0