Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You would attempt to set some constraints on the image dimensions at the different breakpoints. For example, you can use percentages if you want a fluid amount. It's really to tell the browser how much space to allocate to the image before it's loaded. This is an old problem and pages that jump around would happen on slower connections.


Ok, my image has 100% width for screens up to 800 px width, what height value do I have to set? You simply don't know this information at the time when the DOM is built.

The idea to set fixed dimensions feels like it comes from a time where we did designs with tables and "optimized" sites for 1024 x 768 pixel screen size.

That was the time when you could tell that this image should be displayed 200 x 200 px in size and nothing else. And it fit. One way or another.


I would approach this thinking in terms of a known aspect ratio of the images and use a technique like this:

https://www.w3schools.com/howto/tryit.asp?filename=tryhow_cs...

Make no mistake, this is a silly problem to need to hack a solution for. So I would welcome lazy loaded images with space allocation before it's rendered with a responsive sizing.


Oh, constraints! These cute little math things that always work and are fundamental to the definition of layout geometry.

I doubt we’ll ever see them built into a browser, because all nice generalized things never get there.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: