Swap elements using CSS?

前端 未结 6 951
醉酒成梦
醉酒成梦 2021-01-18 16:36

I have fairly simple layout, like this:

1
2
6条回答
  •  半阙折子戏
    2021-01-18 17:08

    You can do this by using (if you only want to do the swap in div.card):

    .card .attack {
       position: relative;
       top: 1em;
    }
    .card .defence {
       position: relative;
       top: -1em;
    }
    

    But as others have mentioned this can have some unintended side-effects. E.g. the above sample will move swap position correctly only for 1 line blocks.

提交回复
热议问题