align-content
Baseline
Widely available
*
This feature is well established and works across many devices and browser versions. Itâs been available across browsers since 2015ë 9ì.
* Some parts of this feature may have varying levels of support.
CSS align-content ìì±ì ì½í
ì¸ ì¬ì´ì ì½í
ì¸ ì£¼ì ë¹ ê³µê°ì íë ì¤ ë°ì¤'ì êµì°¨ì¶ ëë 그리ëì ë¸ë¡ ì¶ì ë°ë¼ ë°°ì¹íë ë°©ìì ê²°ì í©ëë¤.
ìëì ëíí ìì ë 그리ë ë ì´ììì ì¬ì©í´ ì´ ìì±ì ê°ì ìì°í©ëë¤.
ìëí´ ë³´ê¸°
align-content: start;
align-content: center;
align-content: space-between;
align-content: space-around;
<section class="default-example" id="default-example">
<div class="example-container">
<div class="transition-all" id="example-element">
<div>One</div>
<div>Two</div>
<div>Three</div>
</div>
</div>
</section>
#example-element {
border: 1px solid #c5c5c5;
display: grid;
grid-template-columns: 60px 60px;
grid-auto-rows: 40px;
column-gap: 10px;
height: 180px;
}
#example-element > div {
background-color: rgba(0, 0, 255, 0.2);
border: 3px solid blue;
}
ì´ ìì±ì í ì¤ë¡ë§ ì´ë£¨ì´ì§ íë ì¤ ì»¨í
ì´ëìë ì무 í¨ê³¼ë ììµëë¤(flex-wrap: nowrap ë±).
Syntax
/* Basic positional alignment */
/* align-content does not take left and right values */
align-content: center; /* Pack items around the center */
align-content: start; /* Pack items from the start */
align-content: end; /* Pack items from the end */
align-content: flex-start; /* Pack flex items from the start */
align-content: flex-end; /* Pack flex items from the end */
/* Normal alignment */
align-content: normal;
/* Baseline alignment */
align-content: baseline;
align-content: first baseline;
align-content: last baseline;
/* Distributed alignment */
align-content: space-between; /* Distribute items evenly
The first item is flush with the start,
the last is flush with the end */
align-content: space-around; /* Distribute items evenly
Items have a half-size space
on either end */
align-content: space-evenly; /* Distribute items evenly
Items have equal space around them */
align-content: stretch; /* Distribute items evenly
Stretch 'auto'-sized items to fit
the container */
/* Overflow alignment */
align-content: safe center;
align-content: unsafe center;
/* Global values */
align-content: inherit;
align-content: initial;
align-content: revert;
align-content: unset;
ê°
start-
íë ì¤/그리ë í목ì í ë©ì´ë¦¬ë¡ ëì³ì ì ë ¬ 컨í ì´ë êµì°¨ì¶ì ìì 모ì리ì ë°°ì¹í©ëë¤.
end-
íë ì¤/그리ë í목ì í ë©ì´ë¦¬ë¡ ëì³ì ì ë ¬ 컨í ì´ë êµì°¨ì¶ì ë 모ì리ì ë°°ì¹í©ëë¤.
flex-start-
íë ì¤ í목ì í ë©ì´ë¦¬ë¡ ëì¹ê³ , íë ì¤ ì»¨í ì´ëì êµì°¨ ììì ì ë°ë¼ ì ë ¬ 컨í ì´ë 모ì리ì ë°°ì¹í©ëë¤. íë ì¤ ë ì´ìì í목ìë§ ì ì©ë©ëë¤. íë ì¤ ì»¨í ì´ëì ììì´ ìë í목ì ëí´ìë
startë¡ ì·¨ê¸í©ëë¤. flex-end-
íë ì¤ í목ì í ë©ì´ë¦¬ë¡ ëì¹ê³ , íë ì¤ ì»¨í ì´ëì êµì°¨ ëì ì ë°ë¼ ì ë ¬ 컨í ì´ë 모ì리ì ë°°ì¹í©ëë¤. íë ì¤ ë ì´ìì í목ìë§ ì ì©ë©ëë¤. íë ì¤ ì»¨í ì´ëì ììì´ ìë í목ì ëí´ìë
endë¡ ì·¨ê¸í©ëë¤. center-
íë ì¤/그리ë í목ì í ë©ì´ë¦¬ë¡ ëì³ì ì ë ¬ 컨í ì´ë êµì°¨ì¶ì ì¤ìì ë°°ì¹í©ëë¤.
normal-
align-content를 ì§ì íì§ ììì ëì²ë¼, íë ì¤/그리ë í목ì í ë©ì´ë¦¬ë¡ ëì³ì 기본 ìì¹ì ë°°ì¹í©ëë¤. baseline,first baseline,last baseline-
첫 ë²ì§¸ ëë ë§ì§ë§ 기ì¤ì ì ëí´ ëª ìí©ëë¤. ë°ì¤ì 첫 ë²ì§¸ ëë ë§ì§ë§ 기ì¤ì ì§í©ì 기ì¤ì ì ê³µì íë 모ë ë°ì¤ì 첫 ë²ì§¸ ëë ë§ì§ë§ 기ì¤ì ê³¼ ì ë ¬í©ëë¤.
first baselineì ëì²´ ì ë ¬ìstart,last baselineì ëì²´ ì ë ¬ìendì ëë¤. space-between-
ì ë ¬ 컨í ì´ëì êµì°¨ì¶ì ë°ë¼ í목ì ê³ ë¥´ê² ë°°ì¹í©ëë¤. ì´ìí í목ê°ì ê±°ë¦¬ê° ëì¼í´ì§ëë¤. 첫 í목ì ì ë ¬ 컨í ì´ë êµì°¨ì¶ì ììì ì, ë§ì§ë§ í목ì ì ë ¬ 컨í ì´ë êµì°¨ì¶ì ì¢ ë£ì ì ë¶ì ëë¤.
space-around-
ì ë ¬ 컨í ì´ëì êµì°¨ì¶ì ë°ë¼ í목ì ê³ ë¥´ê² ë°°ì¹í©ëë¤. ì´ìí í목ê°ì ê±°ë¦¬ê° ëì¼í´ì§ëë¤. 첫 í목 ì´ì ì¬ë°±ê³¼ ë§ì§ë§ í목 ì´í ì¬ë°±ì ê° íëª©ê° ê±°ë¦¬ì ì ë°ì´ ë©ëë¤.
space-evenly-
ì ë ¬ 컨í ì´ëì êµì°¨ì¶ì ë°ë¼ í목ì ê³ ë¥´ê² ë°°ì¹í©ëë¤. ì´ìí í목ê°ì 거리, 첫 í목 ì´ì ì¬ë°±, ë§ì§ë§ í목 ì´í ì¬ë°±ì´ 모ë ê°ìì§ëë¤.
stretch-
모ë í목ì êµì°¨ì¶ ë°©í¥ í¬ê¸°ì í©ì´ ì ë ¬ 컨í ì´ëë³´ë¤ ìì ê²½ì°, 모ë
autoí¬ê¸°ì íëª©ì´ ëì¼(ë¹ë¡íì§ ìì)íê² ì»¤ì ¸ì ì ë ¬ 컨í ì´ëì êµì°¨ì¶ ë°©í¥ì ê°ë ì±ìëë¤. ë¨, í목ì ì§ì ímax-height/max-widthë±ì í¬ê¸° ì íì ì¤ìí©ëë¤. safe-
ì ë ¬ í¤ìëì í¨ê» ì¬ì©í©ëë¤. 주ì´ì§ í¤ìëë¡ ì¸í´ íëª©ì´ ì ë ¬ 컨í ì´ë ë°ì¼ë¡ ì¤ë²íë¡íê² ëì´ ë°ì´í°ê° ì ì¤ë ì ìì¼ë©´ í목 ì ë ¬ì
start를 ëì ì¬ì©í©ëë¤. unsafe-
ì ë ¬ í¤ìëì í¨ê» ì¬ì©í©ëë¤. 컨í ì´ëì í목ì ìëì í¬ê¸° ë° ì¤ë²íë¡ë¡ ì¸í ë°ì´í° ì ì¤ì ìê´íì§ ìê³ ì£¼ì´ì§ ì ë ¬ì ì¤ìí©ëë¤.
íì ì ì
| ì´ê¸°ê° | normal |
|---|---|
| ì ì©ëì | Block-containers, multi-column containers, flex containers |
| ìì | no |
| ê³ì° ê° | as specified |
| Animation type | discrete |
íì 구문
align-content =
normal |
<baseline-position> |
<content-distribution> |
<overflow-position>? <content-position>
<baseline-position> =
[ first | last ]? &&
baseline
<content-distribution> =
space-between |
space-around |
space-evenly |
stretch
<overflow-position> =
unsafe |
safe
<content-position> =
center |
start |
end |
flex-start |
flex-end
ìì
>CSS
#container {
height: 200px;
width: 240px;
align-content: center; /* Can be changed in the live sample */
background-color: #8c8c8c;
}
.flex {
display: flex;
flex-wrap: wrap;
}
.grid {
display: grid;
grid-template-columns: repeat(auto-fill, 50px);
}
div > div {
box-sizing: border-box;
border: 2px solid #8c8c8c;
width: 50px;
display: flex;
align-items: center;
justify-content: center;
}
#item1 {
background-color: #8cffa0;
min-height: 30px;
}
#item2 {
background-color: #a0c8ff;
min-height: 50px;
}
#item3 {
background-color: #ffa08c;
min-height: 40px;
}
#item4 {
background-color: #ffff8c;
min-height: 60px;
}
#item5 {
background-color: #ff8cff;
min-height: 70px;
}
#item6 {
background-color: #8cffff;
min-height: 50px;
font-size: 30px;
}
select {
font-size: 16px;
}
.row {
margin-top: 10px;
}
HTML
<div id="container" class="flex">
<div id="item1">1</div>
<div id="item2">2</div>
<div id="item3">3</div>
<div id="item4">4</div>
<div id="item5">5</div>
<div id="item6">6</div>
</div>
<div class="row">
<label for="display">display: </label>
<select id="display">
<option value="flex">flex</option>
<option value="grid">grid</option>
</select>
</div>
<div class="row">
<label for="values">align-content: </label>
<select id="values">
<option value="normal">normal</option>
<option value="stretch">stretch</option>
<option value="flex-start">flex-start</option>
<option value="flex-end">flex-end</option>
<option value="center" selected>center</option>
<option value="space-between">space-between</option>
<option value="space-around">space-around</option>
<option value="space-evenly">space-evenly</option>
<option value="start">start</option>
<option value="end">end</option>
<option value="left">left</option>
<option value="right">right</option>
<option value="baseline">baseline</option>
<option value="first baseline">first baseline</option>
<option value="last baseline">last baseline</option>
<option value="safe center">safe center</option>
<option value="unsafe center">unsafe center</option>
<option value="safe right">safe right</option>
<option value="unsafe right">unsafe right</option>
<option value="safe end">safe end</option>
<option value="unsafe end">unsafe end</option>
<option value="safe flex-end">safe flex-end</option>
<option value="unsafe flex-end">unsafe flex-end</option>
</select>
</div>
ê²°ê³¼
ëª ì¸
| Specification |
|---|
| CSS Box Alignment Module Level 3 > # align-justify-content > |
| CSS Flexible Box Layout Module Level 1 > # align-content-property > |
ë¸ë¼ì°ì í¸íì±
ê°ì´ 보기
- CSS Flexbox Guide: Basic Concepts of Flexbox
- CSS Flexbox Guide: Aligning items in a flex container
- CSS Grid Guide: Box alignment in CSS Grid layouts
- CSS Box Alignment