Make second div appear above first, without absolute position or changing html

前端 未结 3 1141
一生所求
一生所求 2020-12-28 15:36

My page is split into 3 slices, as shown in this JFiddle.

In my full source code, I have media queries to help manage sizing between mobile and desktop. When someone

3条回答
  •  一个人的身影
    2020-12-28 16:19

    I tried to solve the solution using transform: translateY property in percentage value.

    Note: This works if and only if the two containers have same height. or if the height is already known, then you can set the transform: translateY value according to the height.

    CSS

    @media (max-width: 700px) {
        #container > div {
            width: auto;
            display: block;
            float: none;
        }
        #container #picture {
            display: none;
        }
        #logo {
            transform: translateY(-100%);
        }
        #items {
            transform: translateY(100%);
        }
    }
    

    Working Fiddle

提交回复
热议问题