CSS에서 flex-wrap 속성에 wrap-reverse 값을 지정하면, 플렉스 컨테이너의 공간이 부족할 때 플렉스 항목(flex item)들이 여러 줄로 나뉘어 배치되되 역방향(아래에서 위로)으로 정렬됩니다. 일반적인 wrap 값과 달리 교차축(cross axis)의 방향이 뒤집히기 때문에, 첫 번째 줄이 화면 하단에 위치하고 이후 줄들이 위쪽으로 쌓이는 형태로 표시됩니다.
예제
아래 코드를 실행하면 wrap-reverse 값이 실제로 어떻게 동작하는지 직접 확인할 수 있습니다.
<!DOCTYPE html>
<html>
<head>
<style>
.mycontainer {
display: flex;
background-color: #D35400;
flex-wrap: wrap-reverse;
}
.mycontainer > div {
background-color: white;
text-align: center;
line-height: 40px;
font-size: 25px;
width: 100px;
margin: 5px;
}
</style>
</head>
<body>
<h1>Quiz</h1>
<div class = "mycontainer">
<div>Ans1</div>
<div>Ans2</div>
<div>Ans3</div>
<div>Ans4</div>
<div>Ans5</div>
<div>Ans6</div>
<div>Ans7</div>
<div>Ans8</div>
<div>Ans9</div>
</div>
</body>
</html>