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

前端 未结 3 1142
一生所求
一生所求 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:22

    Probably the easiest is if you play with minus margins. Note that the below sizes (width and side margins) may need to be adjusted to your specific needs.

    #container * {
        width: 95vw;
        text-align: center;
    }
    
    #items {
        width: 50%; /* #picture is hidden so we split the screen into 2 */
        float: left;
        margin-top:30px; /* has to be smaller than the absolute of #logo */
        margin-left:25%; /* half of the element's width */
    }
    
    #logo {
        width: 50%; /* #picture is hidden so we split the screen into 2 */
        float: right;
        margin-top:-40px; /* its absolute has to be greater than the one of #items */
        margin-right:25%; /* half of the element's width */
    }
    
    #picture {
        width: 33%;
        float: right;
        display:none; /* Hiding #picture as you said you would */
    }
    Items
    Picture

提交回复
热议问题