How to place two divs next to each other?

后端 未结 13 2181
孤独总比滥情好
孤独总比滥情好 2020-11-22 05:44

Consider the following code:

13条回答
  •  佛祖请我去吃肉
    2020-11-22 06:13

    here is the solution:

    #wrapper {
        width: 500px;
        border: 1px solid black;
        overflow: auto; /* so the size of the wrapper is alway the size of the longest content */
    }
    #first {
        float: left;
        width: 300px;
        border: 1px solid red;
    }
    #second {
        border: 1px solid green;
        margin: 0 0 0 302px; /* considering the border you need to use a margin so the content does not float under the first div*/
    }
    

    your demo updated;

    http://jsfiddle.net/dqC8t/1/

提交回复
热议问题