<div id="wrap">
<div class="flexArea jc-center">
<div class="flexItem"></div>
<div class="flexItem"></div>
</div>
<div class="flexArea jc-start">
<div class="flexItem"></div>
<div class="flexItem"></div>
</div>
<div class="flexArea jc-end">
<div class="flexItem"></div>
<div class="flexItem"></div>
</div>
<div class="flexArea jc-between">
<div class="flexItem"></div>
<div class="flexItem"></div>
</div>
<div class="flexArea jc-around">
<div class="flexItem"></div>
<div class="flexItem"></div>
</div>
<div class="flexArea jc-evenly">
<div class="flexItem"></div>
<div class="flexItem"></div>
</div>
</div>
#wrap{padding: 50px; box-sizing: border-box;
.flexArea{display: flex;
.flexItem{display: flex; width: 200px; height: 200px; max-width: 200px; font-size: 16px; font-family: 'Noto Sans';
color: #fff; background-color: #000;
+.flexItem{margin-left: 10px;}
}
&.jc-center{justify-content: center;}
&.jc-start{justify-content: flex-start;}
&.jc-end{justify-content: flex-end;}
&.jc-between{justify-content: space-between;}
&.jc-around{justify-content: space-around;}
&.jc-evenly{justify-content: space-evenly;}
}
}
#wrap{
padding: 50px;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
#wrap .flexArea {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
}
#wrap .flexArea .flexItem {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
width: 200px;
height: 200px;
max-width: 200px;
font-size: 16px;
font-family: 'Noto Sans';
color: #fff;
background-color: #000;
}
#wrap .flexArea .flexItem + .flexItem {
margin-left: 10px;
}
#wrap .flexArea.jc-center {
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
}
#wrap .flexArea.jc-start {
-webkit-box-pack: start;
-ms-flex-pack: start;
justify-content: flex-start;
}
#wrap .flexArea.jc-end {
-webkit-box-pack: end;
-ms-flex-pack: end;
justify-content: flex-end;
}
#wrap .flexArea.jc-between {
-webkit-box-pack: justify;
-ms-flex-pack: justify;
justify-content: space-between;
}
#wrap .flexArea.jc-around {
-ms-flex-pack: distribute;
justify-content: space-around;
}
#wrap .flexArea.jc-evenly {
-webkit-box-pack: space-evenly;
-ms-flex-pack: space-evenly;
justify-content: space-evenly;
}
아래 주소를 복사하여 다른 곳에 붙여넣으세요.
모바일 환경에서는 코드 결과가 gif로 표시됩니다.
그래도 결과를 볼까요?
(제대로 된 결과를 보려면 노트북 또는 데스크탑에서 실행해주세요.)