[CSS]flex/order 자식요소의 순서를 정하는 속성

홍싸리·2023년 5월 9일
0

css

목록 보기
3/4

html

<section>
  <article>1</article>
  <article>2</article>
  <article>3</article>
</section>

css

section{
    display:flex;
    width:100%;
    background:lightcyan;
}
article{
    display:flex;
    justify-content:center;
    align-items:center;
    width:100px;
    height:100px;
    font-size:50px;
    color:#fff;
    text-align:center;
    background:aqua;
    border:1px solid #000;
}
article:nth-of-type(2){
    order:3;
}


2번 article이 3번째에 위치함

이 때, article:nth-of-type(2)의 order를 음수로 줄 수 있다.
음수로 줄 경우, 맨 앞으로 당겨진다.

article:nth-of-type(2){
    order:-3;
}

profile
그럴싸한건 다 따라해보는 프론트엔드 개발자 준비중인 6년차 퍼블리셔

0개의 댓글