How can I reorder my divs using only CSS?

后端 未结 24 1140
傲寒
傲寒 2020-11-22 01:53

Given a template where the HTML cannot be modified because of other requirements, how is it possible to display (rearrange) a div above another div

24条回答
  •  粉色の甜心
    2020-11-22 02:00

    A CSS-only solution (works for IE10+) – use Flexbox's order property:

    Demo: http://jsfiddle.net/hqya7q6o/596/

    #flex { display: flex; flex-direction: column; }
    #a { order: 2; }
    #b { order: 1; }
    #c { order: 3; }
    A
    B
    C

    More info: https://developer.mozilla.org/en-US/docs/Web/CSS/order

提交回复
热议问题