最大宽度 | @viewport.max-width (Device Adaptation) - CSS 中文开发手册 - Break易站
最大宽度 | @viewport.max-width (Device Adaptation) - CSS 中文开发手册
max-widthCSS描述符指定通过定义的文档的视口的最大宽度@viewportat-rule。
默认情况下,在考虑最大宽度约束的情况下,宽度将尽可能接近初始视图。
Related at-rule | @viewport |
---|---|
初始值 | auto |
Percentages | refer to the width of the initial viewport |
适用媒体 | visual, continuous |
计算值 | if specified as a length, the corresponding absolute length; if specified as a percentage, the specified value; otherwise, auto |
正规顺序 | the unique non-ambiguous order defined by the formal grammar |
语法
/* Keyword value */ max-width: auto; max-width: none; /* <length> values */ max-width: 600px; max-width: 80em; max-width: 15cm; /* <percentage> value */ max-width: 75%;
值
auto使用的值是从其他CSS描述符的值中计算出来的。无使用的值是从其他CSS描述符的值中计算出来的。<length>非负的绝对或相对长度。<percentage>相对于初始视口宽度的百分比值,对于水平长度,缩放系数为1.0。必须是非负的。
正式语法
<viewport-length>where <viewport-length> = auto | <length-percentage> where <length-percentage> = <length> | <percentage>
规范
Specification | Status | Comment |
---|---|---|
CSS Device AdaptationThe definition of '"max-width" descriptor' in that specification. | Working Draft | Initial definition |
浏览器兼容性
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | 29 (behind a flag) | No support | 10 -ms | 11.10 Removed in 15 Reintroduced behind a flag in 16 | No support |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | 4.4 | 29 | No support | 10-ms | 11.10 Removed in 15 Reintroduced behind a flag in 16 | No support |