Why `float:left` doesn't work with a fixed width?

前端 未结 7 1318
谎友^
谎友^ 2021-01-02 06:39

I have two divs on a webpage and I would like both of them to have a fixed width and would like the first div to be floated to the left of the second div.

This sound

7条回答
  •  情歌与酒
    2021-01-02 07:16

     div.left {
         float: left;
         width: 200px;
        height:200px;
        background:red;
     }
    
     div.right {
        float:right;
         width: 200px;
         height:200px;
        background:blue;
    }
    

    see http://jsfiddle.net/3kUpF/

    Alternatively, if you want them side by side then you can float:left on both see http://jsfiddle.net/3kUpF/1/

提交回复
热议问题