在线文档教程
CSS

平均宽度 | min-width

最小宽度

min-width CSS属性设置元素的最小宽度。它防止使用的width属性值变得小于指定的值min-width

/* <length> value */ min-width: 3.5em; /* <percentage> value */ min-width: 10%; /* Keyword values */ min-width: max-content; min-width: min-content; min-width: fit-content; min-width: fill-available; /* Global values */ min-width: inherit; min-width: initial; min-width: unset;

当最小宽度大于最大宽度或宽度时, 元素的宽度设置为最小宽度的值。

初始值0
适用于所有元素,但未被替换的行内元素,表行和行组
遗传没有
百分比指的是包含块的宽度
媒体视觉
计算值指定的百分比或绝对长度
动画类型一个长度,百分比或者calc();
规范的顺序形式语法定义的独特的非模糊顺序

语法

取值

<length>最小宽度,表示为a <length>。负值使声明无效。

关键字值

autoFlex项目的默认最小宽度,为其他布局提供比0更合理的默认宽度。

形式语法

<length> | <percentage> | auto | max-content | min-content | fit-content | fill-available

实例

table { min-width: 75%; } form { min-width: 0; }

规范

SpecificationStatusComment
CSS Intrinsic & Extrinsic Sizing Module Level 3The definition of 'min-width' in that specification.Working DraftAdds the max-content, min-content, fit-content, and fill-available keywords. (Both CSS3 Box and CSS3 Writing Modes drafts used to define these keywords, but are superseded by this spec.)
CSS Flexible Box Layout ModuleThe definition of 'min-width' in that specification.Candidate RecommendationAdds the auto keyword and uses it as the initial value.
CSS TransitionsThe definition of 'min-width' in that specification.Working DraftDefines min-width as animatable.
CSS Level 2 (Revision 1)The definition of 'min-width' in that specification.RecommendationInitial definition.

浏览器兼容性

FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support1.0(Yes)1.0 (1.0)7.04.02.0.2 (416), buggy before
applies to <table> 1No supportNo support(Yes)No support(Yes)No support
max-content, min-content, fit-content, and fill-available24.0 -webkit 3No support3.0 (1.9) -moz 2No supportNo supportNo support 3
auto21.0 4?16.0 (16.0) 4 Removed in 22.0 (22.0) Reintroduced in 34.0 (34.0) with the new behavior defined by the spec.No support12.10 6No support
auto as initial value21.0(Yes)18.0 (18.0) Removed in 22.0 (22.0)No support12.10No support

FeatureAndroidChrome for AndroidEdgeFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support??(Yes)????5
applies to <table> 1??No support????
max-content, min-content, fit-content, and fill-available??No support????
auto???????
auto as initial value???????