height
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.
height CSS ìì±ì ììì ëì´ë¥¼ ì§ì í©ëë¤. 기본ê°ì ì½í
ì¸ ììì ëì´ì§ë§, box-sizingì´ border-boxë¼ë©´ í
ë리 ììì ëì´ë¥¼ ì¤ì í©ëë¤.
ìëí´ ë³´ê¸°
height: 150px;
height: 6em;
height: 75%;
height: auto;
<section class="default-example" id="default-example">
<div class="transition-all" id="example-element">
This is a box where you can change the height.
</div>
</section>
#example-element {
display: flex;
flex-direction: column;
background-color: #5b6dcd;
justify-content: center;
color: #ffffff;
}
min-heightì max-height ìì±ì height를 ë®ì´ìëë¤.
구문
css
/* í¤ìë */
height: auto;
/* <length> */
height: 120px;
height: 10em;
/* <percentage> */
height: 75%;
/* ì ì ê° */
height: inherit;
height: initial;
height: unset;
ê°
<length>- : ëì´ì ì ëê°.
<percentage>- : 컨í ì´ë ë¸ë¡ ëì´ì ë°±ë¶ì¨.
border-box- : ìì
<length>ëë<percentage>ê° ììì ë³´ë ë°ì¤ì ì ì©.
- : ìì
content-box- : ìì
<length>ëë<percentage>ê° ììì ì½í ì¸ ë°ì¤ì ì ì©.
- : ìì
auto- : ë¸ë¼ì°ì ê° ììì ëì´ë¥¼ ê³ì°íê³ ì í.
fill- : ê¸ì°ê¸° ë°©í¥ì ë°ë¼
fill-availableì¸ë¼ì¸ í¬ê¸° ëëfill-availableë¸ë¡ í¬ê¸°ë¥¼ ì¬ì©.
- : ê¸ì°ê¸° ë°©í¥ì ë°ë¼
max-content- : 본ì§ì ì¸ ì í¸ ëì´.
min-content- : 본ì§ì ì¸ ìµì ëì´.
available- : 컨í ì´ë ë¸ë¡ ëì´ìì ìí ì¬ë°±, í ë리, í¨ë©ì ì ì¸í ê°.
fit-content- : ë¤ì ì¤ ë í° ê°.
- 본ì§ì ì¸ ìµì ëì´
- 본ì§ì ì¸ ì í¸ ëì´ì ì¬ì© ê°ë¥í ëì´ ì¤ ìì ê°
- : ë¤ì ì¤ ë í° ê°.
íì 구문
height =
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
ìì
>HTML
html
<div id="taller">ì í¤ë 50í½ì
ì
ëë¤.</div>
<div id="shorter">ì í¤ë 25í½ì
ì
ëë¤.</div>
<div id="parent">
<div id="child">ì í¤ë ë¶ëª¨ì ì ë°ì
ëë¤.</div>
</div>
CSS
css
div {
width: 250px;
margin-bottom: 5px;
border: 2px solid blue;
}
#taller {
height: 50px;
}
#shorter {
height: 25px;
}
#parent {
height: 100px;
}
#child {
height: 50%;
width: 75%;
}
ê²°ê³¼
ì ê·¼ì± ê³ ë ¤ì¬í
íì´ì§ë¥¼ íëíê±°ë ê¸ê¼´ í¬ê¸°ë¥¼ ëë ¸ì ë height ìì±ì ì§ì í ììê° ì리거ë ë¤ë¥¸ ë´ì©ì ê°ë¦¬ì§ ìëë¡ íì¸íì¸ì.
ëª ì¸
| Specification |
|---|
| CSS Box Sizing Module Level 3> # preferred-size-properties> |
| CSS Box Sizing Module Level 4> # sizing-values> |
| ì´ê¸°ê° | auto |
|---|---|
| ì ì©ëì | all elements but non-replaced inline elements, table columns, and column groups |
| ìì | no |
| Percentages | The percentage is calculated with respect to the height of the generated box's containing block. If the height of the containing block is not specified explicitly (i.e., it depends on content height), and this element is not absolutely positioned, the value computes to auto. A percentage height on the root element is relative to the initial containing block. |
| ê³ì° ê° | a percentage or auto or the absolute length |
| Animation type | a length, percentage or calc(); |