How to put two divs side by side

前端 未结 8 1097
情深已故
情深已故 2020-12-07 17:20

So I\'m quite new to writing code (about a few weeks) and I\'ve hit a wall while writing code for my website. I want to have a layout like this:

8条回答
  •  暖寄归人
    2020-12-07 18:08

    Based on the layout you gave you can use float left property in css.

    HTML

    
    

    CSS

    body{
    margin:0px;
    height: 100%;
    }
    #header {
    
    background-color: black;
    height: 50px;
    color: white;
    font-size:25px;
    
     }
    
    #wrap {
    
    margin-left:200px;
    margin-top:300px;
    
    
     }
    #box1 {
    width:200px;
    float: left;
    height: 300px;
    background-color: black;
    margin-right: 20px;
    }
    #box2{
    width: 200px;
    float: left;
    height: 300px;
    background-color: blue;
    }
    #clear {
    clear: both;
    }
    #footer {
    width: 100%;
    background-color: black;
    height: 50px;
    margin-top:300px;
    color: white;
    font-size:25px;
    position: absolute;
    }
    

提交回复
热议问题