🔸flex
╱🚧 under construction -> flow/writing direction
Last updated
Was this helpful?
╱🚧 under construction -> flow/writing direction
Last updated
Was this helpful?
Was this helpful?
任何元素設定 display: flex
就會變成 flexbox (flex container),而其內部的子元素會變成 flex items。Flexbox 是一種佈局模式,可以設定容器內元素的排版、對齊、空間分配等方式。
📁 index.html
<!-- flexbox -->
<div class="flexbox">
<!-- flex items -->
<div class="item red">A</div>
<div class="item green">B<br>B</div>
📁 styles.css
/* flexbox */
.flexbox {
display: flex; /* ⭐️ 設定為 Flex 容器 */
flex-direction: row; /* 設定主軸:水平(預設) */
justify-content: space-around; /* 設定主軸對齊:分散 */
align-items: center;
flex-end
:對齊副軸的結束位置。
center
:在副軸上居中對齊。
baseline
:對齊文字基線。
/* CSS */
/* CSS */
/* CSS */
/* CSS */
/* flex container */
.flexbox {
display: flex; /* 設定為 Flex 容器 */
flex-direction: row; /* ⭐ 設定主軸:水平(預設) */
justify-content: space-around; /* 主軸對齊方式:分散 */
align-items: center; /* 副軸對齊方式:居中 */
}
/* flex container */
.flexbox {
display: flex; /* 設定為 Flex 容器 */
flex-direction: row; /* 設定主軸:水平(預設) */
justify-content: space-around; /* ⭐ 主軸對齊方式:分散 */
align-items: center; /* 副軸對齊方式:居中 */
}
/* flex container */
.flexbox {
display: flex; /* 設定為 Flex 容器 */
flex-direction: row; /* 設定主軸:水平(預設) */
justify-content: space-around; /* 主軸對齊方式:分散 */
align-items: center;