EDIT:
If I remove
.box-media-link-container {
float:left;
}
it works as expected. Is there any good explanation for this? Is there any alternative for float:left ? (Other than tables)
Working example (non floated container): http://jsfiddle.net/Kju6z/5/
(Edit 2: Even this is not the holy grail, in more advanced examples - this still fails, even without the float).
If you can run safari 5.1 (via http://browserstack.com or similar) - please check this out. I'm not sure what the cause of this is any more.
.box-media-box .box-media-link {
max-width:75px;
width:auto;
height:auto;
}
.box-media img {
max-width:100%;
height:auto;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
overflow:hidden;
}
The floated image width is not known beforehand, but the image container has a max-width set of 75px (note that in this case, I do know that the image is in fact 100px - but that's just for the example).
The image itself has a max-width of 100% and a height of auto, so that it is responsive.
This seems to work in all browsers except safari, this one doesn't even display the image. It does so at times though, which makes me think the issue may be caused by the images not yet being loaded whilst the CSS is interpreted, could that be?
See attached screenshot for how it looks in Safari 5.1 (the little black bordered circle is supposed to contain the image). It looks as if the image has not loaded yet (since there is no width or height set), but the image never loads. Only when you go to inspect element it either pops up immediately, or after you change any one property.