The <ratio>
CSS data type, used for describing aspect ratios in media queries, denotes the proportion between two unitless values.
The <ratio>
data type consists of a strictly positive <integer>
followed by a forward slash ('/', Unicode U+002F SOLIDUS
) and a second strictly positive <integer>
. Spaces before and after the slash are optional. The first number represents the width, while the second represents the height.
@media screen and (min-aspect-ratio: 16/9) { ... }
Ratio | Usage | |
---|---|---|
4/3 | Traditional TV format in the 20th century. | |
16/9 | Modern "widescreen" TV format. | |
185/100 = 91/50 (non-integer dividends and divisors are not allowed) | The most common movie format since the 1960s. | |
239/100 (non-integer dividends and divisors are not allowed) | "Widescreen," anamorphic movie format. |
Specification | Status | Comment |
---|---|---|
Media Queries The definition of '<ratio>' in that specification. | Recommendation | Initial definition. |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | Yes | Yes | 3.5 | 9 | 9.5 | Yes |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
aspect-ratio
media feature
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/ratio