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

Do your photos scale in your gallery?

This is off the top of my head but if your images are set to a percent based width so they scale (mine are) and you know the aspect ratio of the image then you can set the CSS ‘ aspect-ratio’ property (or there are some other hacks with padding on a wrapper div) to maintain the height.

You’d probably want to integrate this into the build process but I have not done this.



You don't even need the recently-added aspect-ratio property. In most up-to-date browsers you can now just add the height and width attributes to the img tag and the aspect ratio will render correctly even for responsive images:

https://www.smashingmagazine.com/2020/03/setting-height-widt...




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

Search: