Zest.

CSS: Aspect ratio

A short, tested CSS example for aspect ratio. Copy it and adjust the names and paths for your project.

CSS
.video { aspect-ratio: 16 / 9; width: 100%; }
.avatar { aspect-ratio: 1; object-fit: cover; border-radius: 50%; }

Find it in Zest

Search for “css aspect ratio” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.

More CSS examples

All CSS examples