5

Upgrading our CSS habits: aspect-ratio

 1 year ago
source link: https://christianheilmann.com/2023/04/20/upgrading-our-css-habits-aspect-ratio/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Upgrading our CSS habits: aspect-ratio

Thursday, April 20th, 2023 at 7:34 am

The CSS aspect-ratio property is pretty amazing. You can define a ratio of width to height and it will resize the element accordingly.

Resizing an element to different aspect ratios

You can try it out in this pen :

Where this shines is videos, image content and embeds. No more hacks with relative positioning and percentages. Browser support is green all over, so, like me, it makes sense to upgrade your CSS habits.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK