오늘은 CSS flex 개념에 대해서 배웠는데.. 한번에 이해하려니 너무 힘들어서... 정리를 해보려고 한다.. 구글링을 하던 중 정말 정리를 잘해둔 블로그를 하나 찾아서 블로그 내용과 함께 오늘 배운 내용을 복습 해보려고 한다! (링크는 아래에 있다)
.container {
display : flex;
}
아이템들이 배치된 방향의 축을 메인축(Main Axis), 메인축과 수직인 축을 수직축 또는 교차축(Cross Axis)이라고 부르는데 내가 참고한 블로그에서 아주 신박한 방법을 제시했다
바로 메인축을 오뎅 꼬치라고 생각하면 된다고 한다
flex-direction: row;
// 아이템들이 행(가로) 방향으로 배치됩니다.
flex-direction: column;
//아이템들이 열(세로) 방향으로 배치됩니다.
flex-direction: row-reverse;
//아이템들이 역순으로 가로 배치됩니다.
flex-direction: column-reverse;
//아이템들이 역순으로 세로 배치 됩니다.
.container {
flex-wrap: nowrap;
//줄바꿈 X, 넘치면 그냥 삐져 나감
flex-wrap: wrap;
//줄바꿈 O, float이나 inline-block으로 배치한 요소들과 비슷하게 동작
flex-wrap: wrap-reverse;
//줄바꿈 O, 아이템을 역순으로 배치
}
.container {
flex-flow: row wrap;
아래의 두 줄을 줄여 쓴 것
flex-direction: row;
flex-wrap: wrap;
}
이후에 justify 와 align 개념이 나오는데 여기서 또 신박한 설명이 나온다
저스트 가로 아 수직이다
.container {
justify-content: flex-start;
justify-content: flex-end;
justify-content: center;
justify-content: space-between;
justify-content: space-around;
justify-content: space-evenly;
}
.container {
align-items: stretch;
align-items: flex-start;
align-items: flex-end;
align-items: center;
align-items: baseline;
}
justify-content: center;
align-item: center;
를 해주면 가운데 정렬이 쉽다
.container {
flex-wrap: wrap;
align-content: stretch;
align-content: flex-start;
align-content: flex-end;
align-content: center;
align-content: space-between;
align-content: space-around;
align-content: space-evenly;
}