기본 값 -> 축 방향도 변경이 가능하다

1)display -outside

빨간 박스를 기준으로 바깥 앞,뒤 초록 박스 요소들간의 관계를 정의한 것
2) display - inside : 컨테이너 안의 요소를 어떻게 다룰지를 정의하는 것

빨간 박스 안에 있는 요소들을 어떻게 배치할것인지를 정의하는 것
🙆♀️display 를 설정하는건 컨테이너에다가 display 속성을 정의하는 것이라는 걸 잊지말자 , 이제 배우는 요소들이 container 에 적용하는 것인지 items 에 적용하는것임을 구분지어서 생각하자

/*flex-direction은 container 속성이기에 컨테이너에 지정*/
.container{
border: 5px dashed yellow ;
display:flex;
flex-direction: row;
}
.item{
width: 50px;
height: 50px;
margin: 5px;
background-color: paleturquoise;
border: 3px solid blue;
font-size:30px;
}

.container{
border: 5px dashed yellow ;
display:flex;
flex-direction: row-reverse;
}

.container{
border: 5px dashed yellow ;
display:flex;
flex-direction: column;
}

.container{
border: 5px dashed yellow ;
display:flex;
flex-direction: column-reverse;
}

nowrap : 기본 설정값으로 ,flex-container 부모 요소의 영역을 벗어나더라도 flex-item 요소들을 한 줄에 배치한다 시작점은 flex-direction에 의해 결정된 방향으로 적용
wrap : flex-item요소들이 내부 로직에 의해 분할되어 여러 행에 걸쳐서 배치 일반적으로 위에서 아래로 쌓이는 순서 , item 들이 자신의 너비와 높이를 잃지 않으려고 랩핑을 해준다고 이해하자
.container{
border: 5px dashed yellow ;
display:flex;
flex-wrap: wrap;
}
.item{
width: 50px;
height: 50px;
margin: 5px;
background-color: paleturquoise;
border: 3px solid blue;
font-size:30px;
}

-> item 들이 자신의 width 을 유지하기 때문에 나열이 container 의 너비보다 커지면 다음 줄로 넘어간다
.container{
border: 5px dashed yellow ;
display:flex;
flex-wrap: wrap-reverse;
}

flex-flow : row wrap
.container{
border: 5px dashed yellow ;
display:flex;
justify-content:flex-start;
}
.item{
width: 50px;
height: 50px;
margin: 5px;
background-color: paleturquoise;
border: 3px solid blue;
font-size:30px;
}

.container{
border: 5px dashed yellow ;
display:flex;
justify-content:flex-end;
}

.container{
border: 5px dashed yellow ;
display:flex;
justify-content:center;
}

-> 주축을 기준으로 가운데 정렬이된다
.container{
border: 5px dashed yellow ;
display:flex;
justify-content:space-between;
}

-> 파란색 부분의 간격이 똑같다
.container{
border: 5px dashed yellow ;
display:flex;
justify-content:space-around;
}


justify-content는 연두색 박스 안에서 아이템들을 어떻게 정렬할건지에 대한 이야기
align -items 는 전체 컨테이너에서 연두색을 어디에 정렬할건지를 이야한다
.container{
border: 5px dashed yellow ;
display:flex;
flex-wrap:warp;
align-items : center;
}

.container{
border: 5px dashed yellow ;
display:flex;
justify-content:space-between;
align-items: flex-start;
}
.item{
width: 50px;
height: 50px;
margin: 5px;
background-color: paleturquoise;
border: 3px solid blue;
font-size:30px;
}



.container{
border: 5px dashed yellow ;
display:flex;
justify-content:space-between;
flex-wrap: wrap;
align-content: flex-start;
}
.item{
width: 150px;
height: 50px;
margin: 5px;
background-color: paleturquoise;
border: 3px solid blue;
font-size:30px;
}





flex 혹은 grid 아이템에서 현재 아이템의 배치 순서를 지정한다
기본값 0 -> 0이라면 html 의 코드 순서를 따라가게된다
마이너스 값도 사용 가능 기본값들 보다 앞으로 사용하고 싶을 때 사용
화면에 보이는 순서에만 영향을 준다 (탭 키 동작과는 무관함)
.container{
border: 5px dashed yellow ;
display:flex;
flex-wrap: flex;
}
.item{
width: 50px;
height: 50px;
margin: 5px;
background-color: paleturquoise;
border: 3px solid blue;
font-size:30px;
}
.item:nth-child(3){
order:-1
}

현재 item들이 각자의 h.w 를 가지고 배치된 모습

.container{
border: 5px dashed yellow ;
display:flex;
flex-wrap: flex;
}
.item{
width: 50px;
height: 50px;
margin: 5px;
background-color: paleturquoise;
border: 3px solid blue;
font-size:30px;
flex-grow : 1;
}
flex-grow: 1로 설정하면 각자 아이템들이 남은 공간을 1씩 나눠서 갖는다

flex 박스를 전부 다 같은 값으로만 설정하지 않을 수 있다
.item:nth-child(2){
flex-grow: 2;
}
.itme:nth-child(3){
flex-grow : 1
}

📌 동적으로 만드는 헤더나 너비게이션 바를 사용하는데 주로 사용된다
.container{
hegiht: 200px;
border: 5px dashed yellow ;
display:flex;
flex-wrap: flex;
}
.item{
width: 50px;
height: 50px;
margin: 5px;
background-color: paleturquoise;
border: 3px solid blue;
font-size:30px;
}
.item:nth-child(1){
flex-shrink:0;
}

📌 1번만 크기가 줄어들지 않고 자신의 content 박스의 크기를 지키고 있음 줄어든 크기를 2,3 번이 1번꺼까지 나눠가져서 더 줄어들고 있다
.item:nth-child(3){
flex-shrink:2;
}

📌 3번이 줄어드는 크기가 훨씬 더 빠르다 줄어든 영역을 2번과 3번이 나눠서 줄어들었다

.container{
hegiht: 200px;
border: 5px dashed yellow ;
display:flex;
}
.item{
width: 50px;
height: 50px;
margin: 5px;
background-color: paleturquoise;
border: 3px solid blue;
font-size:30px;
flex-grow:1;
}

-> 주황색 영역을 맞춰줘야지 같은 크기로 grow 가 먹ㅎㄹ 수 있는 것이다
.container{
hegiht: 200px;
border: 5px dashed yellow ;
display:flex;
}
.item{
width: 50px;
height: 50px;
margin: 5px;
background-color: paleturquoise;
border: 3px solid blue;
font-size:30px;
flex-grow:1;
flex-basis: 100px;
}

-> 주황색 영역이 grow : 1 해서 1:1:1로 지정될것이다 , 빨간색 영역이 flex-basis : 100px 지정해준 부분이다
.container{
hegiht: 200px;
border: 5px dashed yellow ;
display:flex;
}
.item{
width: 50px;
height: 50px;
margin: 5px;
background-color: paleturquoise;
border: 3px solid blue;
font-size:30px;
flex-grow:1;
flex-basis: 0;
}

-> 기본 베이스 영역이 1로 아이템들 가로길이 그 자체가 1:1:1이 되는 것이다
.item:nth-child(1){
flex-grow:5;
}
.item:nth-child(2){
flex-grow:1;
}
.item:nth-child(3){
flex-grow:3;
}

-> flex-basis 를 0으로 설정했기 때문에 기본 아이템들이 차지하는 영역이 0으로 같고 이들을 각각 5,1,3 (contentbox 기준) 으로 늘어나도록 설정된 결과를 확인할 수 있다
📌flex-grow 나 flex-shrink 를 설정할 때 flex-basis 을 설정을 해줘야지 원하는 만큼 정확하게 늘어나고 줄어들고의 비율이 계산될것이다
초기값
- flex-grow:0
- flex-shrink:1
- flex-basis : auto
🚨 주의해야할 점
flex : 1 2 (0) ;
한개 또는 두개의 단위 없는 숫자 값을 사용할 때 flex-basic의 값은 auto가 아니라 0이됩니다(0이 여야지 비율을 계산하는게 더 편하기는 하다 완벽하게 비율 요소를 잡아주기 때문에!! )
.container{
border: 5px dashed yellow ;
display:flex;
flex-wrap:warp;
align-items : center;
}

이러한 상태에서 4번만 위로 붙여주고 싶다면
.item:nth-child(4){
align-self: flex-start;
}
