Height of outer div not expanding with inner div

后端 未结 5 1898
遇见更好的自我
遇见更好的自我 2020-12-30 03:52

I have a bodyMain div of 100% width. Inside it is a body div 800px with auto margin(can I use \'body\' as id ?). Inside this are two divs bodyLeft and bodyRight 200px and 60

5条回答
  •  醉话见心
    2020-12-30 04:14

    jsFiddle demo

    *{
        margin:0;
        padding:0;
    }
    
    #bodyMain{
        position:relative;
        overflow:hidden; /*added*/
        border:1px solid red;
        /*removed height:auto;*/
        /*removed width:100%;*/
    }
    #body{
        display:table;/*added*/
        border:1px solid green;
        width:804px;
        margin: 0 auto; /*improved*/
    }
    #bodyLeft{
        border:1px solid blue;
        float:left;
        width:200px;
        /*removed height:auto;*/
    }
    #bodyRight{
        border:1px solid orange;
        float:right;
        width:600px;
        /*removed height:auto;*/
    }
    

提交回复
热议问题