[whatwg] Scaling

fantasai fantasai.lists at inkedblade.net
Mon Jan 14 19:26:05 PST 2008


Nikola Mitic wrote:

> fantasai wrote:
>>
>> Michael wrote (on www-style):
>>>
>>> I have a fluid layout so it changes width because of the browser window.
>>> There is the slight problem that some of the images I use might be too wide.
>>> So I use max-width:100% to prevent this from happening.  This works great
>>> when the image does not have a width or height attribute set.  The image
>>> remains in proportion. (...) But if the height attribute is set, it retains
>>> this height and the image goes out of proportion. 
>>> I think we need some property for this (...)
>>
>> Set img { height: auto; } and your images should size proportionally. 
>
> Is there any way to prevent page from being pushed down by image height 
> when full image get loaded if we didn't define exact image height?

Depends on the situation. You can put a container around the image that has a
fixed height, but it will leave extra space if the max-height: 100% kicks in.

If HTML5 defines the 'width' and 'height' attributes as suggesting the intrinsic
size of the image, browsers could use that information to calculate a tentative
aspect ratio. That would make it possible to size the unloaded-image box even
when one dimension is auto.

~fantasai



More information about the whatwg mailing list