在线文档教程
CSS

比率 | <ratio>

<ratio>

<ratio>CSS数据类型,用于描述媒体查询的纵横比,表示两个无单位值之间的比例。

语法

比率由的组成为:严格的正数 <integer>,以及后面斜杠 ('/', Unicode U+002F SOLIDUS),和后面第二个严格的正数 <integer>

实例

RatioUsage
4/3Traditional TV format in the 20th century.
16/9Modern "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.

规范

SpecificationStatusComment
Media QueriesThe definition of '<ratio>' in that specification.RecommendationInitial definition.

浏览器兼容性

FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support(Yes)3.5 (1.9.1)99.5(Yes)

FeatureAndroidFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
Basic support(Yes)(Yes)?(Yes)(Yes)