試一試
min-width: 150px;
min-width: 20em;
min-width: 75%;
min-width: 40ch;
<section class="default-example" id="default-example">
<div class="transition-all" id="example-element">
Change the minimum width.
</div>
</section>
#example-element {
display: flex;
flex-direction: column;
background-color: #5b6dcd;
height: 80%;
justify-content: center;
color: white;
}
語法
css
/* <length> value */
min-width: 3.5em;
min-width: anchor-size(width);
min-width: anchor-size(--my-anchor self-inline, 200%);
/* <percentage> value */
min-width: 10%;
/* Keyword values */
min-width: max-content;
min-width: min-content;
min-width: fit-content;
min-width: fit-content(20em);
min-width: stretch;
/* Global values */
min-width: inherit;
min-width: initial;
min-width: revert;
min-width: revert-layer;
min-width: unset;
值
<length>-
將
min-width定義為絕對值。 <percentage>-
將
min-width定義為包含塊寬度的百分比。 auto-
預設值。指定元素的自動值來源取決於其顯示值。對於塊級盒、行內盒、行內塊以及所有表格佈局盒,
auto解析為0。對於彈性專案和網格專案,最小寬度值為指定的建議尺寸(例如
width屬性的值)、轉移尺寸(如果元素設定了aspect-ratio且高度是確定的尺寸,則計算得出),否則使用min-content尺寸。如果彈性或網格專案是滾動容器,或者如果網格專案跨越多個彈性列軌道,則自動最小尺寸為0。 max-content-
固有的首選
min-width。 min-content-
固有的最小
min-width。 fit-content-
使用可用空間,但不超過
max-content,即min(max-content, max(min-content, stretch))。 fit-content(<length-percentage>)-
使用
fit-content公式,並將可用空間替換為指定引數,即min(max-content, max(min-content, argument))。 stretch-
將元素外邊距盒的最小寬度限制為其包含塊的寬度。它試圖使外邊距盒填充包含塊中的可用空間,因此在某種程度上行為類似於
100%,但將結果尺寸應用於外邊距盒,而不是由 box-sizing 確定的盒。注意:要檢視瀏覽器用於
stretch值的別名及其實現狀態,請參閱瀏覽器相容性部分。
正式定義
正式語法
min-width =
auto |
<length-percentage [0,∞]> |
min-content |
max-content |
fit-content( <length-percentage [0,∞]> ) |
<calc-size()> |
<anchor-size()> |
stretch |
fit-content |
contain
<length-percentage> =
<length> |
<percentage>
<calc-size()> =
calc-size( <calc-size-basis> , <calc-sum> )
<anchor-size()> =
anchor-size( [ <anchor-name> || <anchor-size> ]? , <length-percentage>? )
<calc-size-basis> =
<size-keyword> |
<calc-size()> |
any |
<calc-sum>
<calc-sum> =
<calc-product> [ [ '+' | '-' ] <calc-product> ]*
<anchor-name> =
<dashed-ident>
<anchor-size> =
width |
height |
block |
inline |
self-block |
self-inline
<calc-product> =
<calc-value> [ [ '*' | / ] <calc-value> ]*
<calc-value> =
<number> |
<dimension> |
<percentage> |
<calc-keyword> |
( <calc-sum> )
<calc-keyword> =
e |
pi |
infinity |
-infinity |
NaN
示例
設定最小元素寬度
css
table {
min-width: 75%;
}
form {
min-width: 0;
}
規範
| 規範 |
|---|
| CSS Box Sizing Module Level 4 # sizing-values |
瀏覽器相容性
載入中…