DEV Community

Cover image for aspect-ratio in css
Ali-Eldeba
Ali-Eldeba

Posted on

aspect-ratio in css

Usage :

Ther is a property in css called aspect-ratio
for example you have a video on your website its dimensions is 16:9 in the mobile media you have to resize it so it probably will lose its dimensions, so we can do that

video {
aspect-ratio: 16 / 9;
}

now you can resize it as you want!

My Question :

  • My Question here is there any prefixes for this property ?
  • I have searched a lot and i really want to know!

Top comments (1)

Collapse
 
timhuang profile image
Timothy Huang

No prefixes needed, just use aspect-ratio property. You can check caniuse: caniuse.com/mdn-css_properties_asp...

Please also check my post: dev.to/timhuang/an-easy-way-to-kee...

This is really an simple way to keep aspect ratio.