max-width
Baseline
Widely available
*
This feature is well established and works across many devices and browser versions. Itâs been available across browsers since 2015ë 7ì.
* Some parts of this feature may have varying levels of support.
max-width CSS ìì±ì ììì ìµë ëë¹ë¥¼ ì¤ì í©ëë¤. max-widthë width ìì±ì ì¬ì©ê°ì´ ìì ì ê°ë³´ë¤ 커ì§ë걸 ë°©ì§í©ëë¤.
ìëí´ ë³´ê¸°
max-width: 150px;
max-width: 20em;
max-width: 75%;
max-width: 20ch;
<section class="default-example" id="default-example">
<div class="transition-all" id="example-element">
Change the maximum width.
</div>
</section>
#example-element {
display: flex;
flex-direction: column;
background-color: #5b6dcd;
height: 80%;
justify-content: center;
color: #ffffff;
}
max-widthê° width를 ì¬ì¤ì íê³ , min-heightê° max-width를 ì¬ì¤ì í©ëë¤.
구문
/* <length> ê° */
max-width: 3.5em;
/* <percentage> ê° */
max-width: 75%;
/* í¤ìë ê° */
max-width: none;
max-width: max-content;
max-width: min-content;
max-width: fit-content;
max-width: fill-available;
/* ì ì ê° */
max-width: inherit;
max-width: initial;
max-width: unset;
ê°
<length>- : ê³ ì 길ì´ë¡ ëíë¸ ìµë ëë¹.
<percentage>- : 컨í ì´ë ë¸ë¡ ëë¹ì ëí ë°±ë¶ì¨ë¡ ëíë¸ ìµë ëë¹.
í¤ìë ê°
none-
ìµë ëë¹ë¥¼ ì íì§ ìì.
max-content-
본ì§ì ì¸ ì í¸ ëì´.
min-content-
본ì§ì ì¸ ìµì ëì´.
fill-available-
컨í ì´ë ë¸ë¡ì ëì´ìì ê°ë¡ì¶ ì쪽 ë° ë°ê¹¥ ì¬ë°±ê³¼ í ë리ì ê³µê°ì ì ì¸í ëì´. (ì¼ë¶ ë¸ë¼ì°ì ë ë§¤ì° ì¤ë ë ì´ë¦ì¸
availableë¡ êµ¬íí¨ì ì°¸ê³ íì¸ì.) fit-content-
max-contentì ëì¼.
íì 구문
max-width =
none |
<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
ìì
ë¤ì ìì ìì, ìì(child) ììì ëë¹ë 150í½ì
ê³¼ ë¶ëª¨(parent) ììì ëë¹ ì¤ ë ìì ê°ì´ ë©ëë¤.
<div id="parent">
<div id="child">
Fusce pulvinar vestibulum eros, sed luctus ex lobortis quis.
</div>
</div>
#parent {
background: lightblue;
width: 300px;
}
#child {
background: gold;
width: 100%;
max-width: 150px;
}
fit-content ê°ì ì¬ì©íì¬ í´ë¹ ììì ë´ì©ì´ íìë¡ íë ëë¹ë§ ì°¨ì§íëë¡ ì¤ì í ì ììµëë¤.
<div id="parent">
<div id="child">Child Text</div>
</div>
#parent {
background: lightblue;
width: 300px;
}
#child {
background: gold;
width: 100%;
max-width: -moz-fit-content;
max-width: -webkit-fit-content;
}
ì ê·¼ì± ê³ ë ¤ì¬í
íì´ì§ì íë ëë ê¸ì¨ í¬ê¸°ë¥¼ í¤ì´ íìë max-width를 ì¤ì í ììì ë´ì©ì´ ì리거ë, ë¤ë¥¸ ìì를 ê°ë¦¬ì§ ìëë¡ ì£¼ìíì¸ì.
ëª ì¸
| Specification |
|---|
| CSS Box Sizing Module Level 4 > # sizing-values > |
| ì´ê¸°ê° | none |
|---|---|
| ì ì©ëì | all elements but non-replaced inline elements, table rows, and row groups |
| ìì | no |
| Percentages | refer to the width of the containing block |
| ê³ì° ê° | the percentage as specified or the absolute length or none |
| Animation type | a length, percentage or calc(); |