Re: naturalHeight and naturalWidth

On 8/8/13 8:52 PM, Benjamin Lord wrote:
> This isn't specc'ed anywhere that I know of, but browsers figured it out for <img> elements a long time ago.

It's specced for <img> at 
http://www.w3.org/TR/CSS21/visudet.html#inline-replaced-width and 
http://www.w3.org/TR/CSS21/visudet.html#inline-replaced-height and the 
interaction with min-width and max-width is specced at 
http://www.w3.org/TR/CSS21/visudet.html#min-max-widths (see the part 
starting "for replaced elements with an intrinsic ratio and both 'width' 
and 'height' specified as 'auto', the algorithm is as follows").

So anything that's got a CSS box and an intrinsic ratio should get this 
behavior automatically.  Note that this setup doesn't need an intrinsic 
width and intrinsic height; just a ration is enough.  This is why <svg> 
with percentage intrinsic dimensions in an HTML page behaves sanely: the 
percentages don't give you an intrinsic width and height but they do 
give you an intrinsic ratio.

Your constrainedProportion suggestion seems to be a way to explicitly 
specify an intrinsic ration as input to this algorithm, right?

It seems like even for things that aren't CSS boxes it should be 
possible to reference this algorithm...

-Boris

Received on Friday, 9 August 2013 01:27:18 UTC