4nduril / my-website

My website: turned inside out
http://tobias-barth.net
0 stars 0 forks source link

Firefox bug: scale images in flex-containers #17

Closed 4nduril closed 9 years ago

4nduril commented 9 years ago

Firefox (mind. bis FF 36.0a2) hat einen Bug, der imgs innerhalb von flex items betrifft: Wenn dem img die Eigenschaft max-width mit einem Prozent-Wert wie 100% zugewiesen wird, ignoriert Firefox das und vergrößert bei zu kleiner device-width das umgebende Element, das Kind eines Containers mit display: flex ist, auf die Originalbreite der Bild-Datei.

Beispiel (CodePen)

Ich habe einen Javascript-Workaround geschrieben, der aber nur leidlich funktioniert. (Er basiert darauf, dass der Bug nicht auftritt, wenn man die relative Einheit vw anstatt % verwendet.) Das muss ordentlich gemacht werden.

Firefox (at least to FF 36.0a2) has a Bug which hits imgs within flexbox items: When the img has set a max-width with a percentage like 100%, Firefox ignores this. Instead, when the device width is smaller than the image source, Firefox enlarges the flex item containing the image to the inherent width of the image source file.

Example (CodePen)

I wrote a JavaScript workaround but it doesn't work that well. (It's based on the fact that the bug doesn't appear when you use the relative unit vw instead of %.) Have to do this better.