How can I reorder my divs using only CSS?

后端 未结 24 1143
傲寒
傲寒 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:02

    It is easy with css, just use display:block and z-index property

    Here is an example:

    HTML:

    
        
    header
    content

    CSS:

    .wrapper
    {
        [...]
    }
    
    .header
    {
        [...]
        z-index:9001;
        display:block;
        [...]
    }
    
    .content
    {
        [...]
        z-index:9000;
        [...]
    }
    

    Edit: It is good to set some background-color to the div-s to see things properly.

提交回复
热议问题