Skip to content

Instantly share code, notes, and snippets.

.wrapper-class {
display: block;
position: relative;
overflow: hidden;
height: 0;
// Give parent container a percentile padding to top, to reserve place of image.
// Then just position the child element (image) absolute.
// height px / width px * 100 = ratio in %
// e.g: 536 / 1024 * 100 = 52,344%