IT/- 프로그래밍

반응형웹 플렉스 아이템 배치 순서 바꾸기

혁준7519 2016. 8. 28. 15:29

플렉스 아이템 배치 순서 바꾸기



플렉서블 배치 순서 바꾸기

order: 0(기본값) (플렉스 아이템에 적용)



css

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
@charset "utf-8";
/**
플렉서블 배치 순서 바꾸기
order: 0(기본값) (플렉스 아이템에 적용)
*/
/* 두번째 셋번째 첫번째 순으로 아이템 배치 */
/* 전체박스 */
#wrap {
    display: flex;
    width: 90%;
    height: 300px;
    margin: 0 auto;
    border: 4px solid #00f;
}
/* 플렉스 아이템 */
#wrap div {
    width: 33.3%;
}
/* 첫번째 아이템 */
#wrap div:first-child {
    order: 3;
    background: #eb4a24;
}
/* 두번째 아이템 */
#wrap div:nth-child(2) {
    order: 1;
    background: #1488c8;    
}
/* 마지막 아이템 */
#wrap div:last-child {
    order: 2;
    background: #f7e041;
}
 
cs



html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" 
          content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">
    <!-- css 파일 임포트 -->
    <link rel="stylesheet" href="04-7.css" />
    <title>Insert title here</title>
</head>
 
<body>
<div id="wrap">
    <div>1</div><div>2</div><div>3</div>
</div>
</body>
</html>
cs



결과

두번째 셋번째 첫번째 순으로 아이템 배치