728x90
플렉스 박스 항목을 배치하는 속성
종류 | 설명 |
justify-content | 주축 방향의 정렬 방법 |
align-items | 교차축 방향의 정렬 방법 |
align-self | 교차축에 있는 개별 항목의 정렬 방법 |
align-content | 고챠축에서 여러 줄로 표시된 항목의 정렬 방법 |
display 속성
- flex - 블록레벨 요소로 배치
- inline-flex 인라인 레벨 요소로 배치
플렉스 항목의 줄을 바꾸는 flex-wrap 속성
- nowrap - 플렉스 항목을 한줄에 표시 (default)
- wrap - 여러줄에 표시
- wrap-reverse - 여러줄에 표시하되, 시작점과 끝점이 바뀜
배치방향과 줄 바꿈을 한번에 지정하는 flex-flow 속성
cf) {flex-flow : row wrap;} - 왼쪽에서 오른쪽, 여러줄
#a {flex-flow : row wrap;} - 왼쪽에서 오른쪽, 여러 줄
#a {flex-flow : row nowrap;} - 왼쪽에서 오른쪽, 한 줄
justifty-content 속성 ( 플렉스 항목 간의 정렬 방법)
#a {justify-content: flex-start;} /* 주축 시작점 기준 */
#a {justify-content: flex-end;} /* 주축 끝점 기준 */
#a {justify-content: center;} /* 주축 중앙 기준 */
#a {justify-content: space-between;} /* 시작 점과 끝 점 배치 후 같은 간격 */
#a {justify-content: space-around;} /* 전체 항목 같은 간격 */
align-items 속성 ( 교차축 정렬 방법)
#a {align-items: flex-start;} /* 주축 시작점 기준 */
#a {align-items: flex-end;} /* 주축 끝점 기준 */
#a {align-items: center;} /* 주축 중앙 기준 */
#a {align-items: baseline;} /* 문자 기준선에 맞춰 배치 */
#a {align-items: stretch;} /* 항목을 늘려 교차축에 가득 차게 배치 */
<!DOCTYPE html>
<html lang="en">
<head>
<style>
.con{
background-color: aliceblue;
height: 100vh;
display: flex; /*span처럼 가로방향으로 자신의 width만큼 배치됨*/
flex-direction: row-reverse;
}
.item1{
background-color: red;
}
.item2{
background-color: orange;
}
.item3{
background-color: yellow;
}
.item4{
background-color: green;
}
.item5{
background-color: blue;
}
</style>
</head>
<body>
<div class="con">
<div class="item1">1</div>
<div class="item2">2</div>
<div class="item3">3</div>
<div class="item4">4</div>
<div class="item5">5</div>
</div>
</body>
</html>
728x90
'StyleSheet > CSS' 카테고리의 다른 글
[CSS] transition & animation (0) | 2024.03.27 |
---|---|
[CSS] transform (0) | 2024.03.27 |
[CSS]배경 이미지 넣기 (0) | 2024.03.27 |
[CSS] 간단 예시 (0) | 2024.03.27 |
[CSS] 표 꾸미기 (0) | 2024.03.26 |