<ratio>
CSS
data type
, used for describing
aspect ratios
in
media queries
, denotes the proportion between two unitless values.
In Media Queries Level 3, the
<ratio>
data type consisted 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.
In Media Queries Level 4, the <ratio> date type is updated to consist of a strictly positive
<number>
followed by a forward slash ('/', Unicode
U+002F SOLIDUS
) and a second strictly positive
<number>
. In addition a single
<number>
as a value is allowable.
@media screen and (min-aspect-ratio: 16/9) { ... }
| Ratio | 用法 | |
|---|---|---|
|
4/3
|
Traditional TV format in the 20 th century. |
|
16/9
|
Modern "widescreen" TV format. |
|
185/100
=
91/50
|
The most common movie format since the 1960s. |
|
239/100
|
"Widescreen," anamorphic movie format. |
| 规范 | 状态 | 注释 |
|---|---|---|
|
Media Queries Level 4
The definition of '<ratio>' in that specification. |
候选推荐 | |
|
Media Queries
The definition of '<ratio>' in that specification. |
推荐 | 初始定义。 |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| <ratio> | Chrome 完整支持 3 | Edge 完整支持 12 | Firefox 完整支持 3.5 | IE 完整支持 9 | Opera 完整支持 9.5 | Safari 完整支持 5 | WebView Android 完整支持 ≤37 | Chrome Android 完整支持 18 | Firefox Android 完整支持 4 | Opera Android 完整支持 14 | Safari iOS 完整支持 4.2 | Samsung Internet Android 完整支持 1.0 |
| Accepts <number> / <number> or single <number> as a value. | Chrome 不支持 No | Edge 不支持 No |
Firefox
完整支持
70
Disabled
|
IE 不支持 No | Opera 不支持 No | Safari 不支持 No | WebView Android 不支持 No | Chrome Android 不支持 No | Firefox Android 不支持 No | Opera Android 不支持 No | Safari iOS 不支持 No | Samsung Internet Android 不支持 No |
完整支持
不支持
用户必须明确启用此特征。
aspect-ratio
media feature
<angle-percentage>
<angle>
<basic-shape>
<blend-mode>
<custom-ident>
<dimension>
<frequency-percentage>
<frequency>
<gradient>
<image>
<integer>
<length-percentage>
<length>
<number>
<percentage>
<ratio>
<resolution>
<shape>
<string>
<time-percentage>
<time>
<transform-function>
<url>
color
flex
ident
position