Basic CSS positioning (fitting children in container)

后端 未结 4 525
我寻月下人不归
我寻月下人不归 2021-01-16 03:57

Very basic CSS question. Given the code shown in http://jsfiddle.net/danwoods/65X7X/ why don\'t the child divs (the colored blocks) fit into the container eleme

4条回答
  •  梦毁少年i
    2021-01-16 04:45

    Because inline elements are sensitive to white space. You can remove them so the HTML looks like:

    jsFiddle example

    Or float the divs left:

    .one,.two,.three {
        float:left;
    }
    

    jsFiddle example

    Or use HTML comments to eat up the white space:

    jsFiddle example

提交回复
热议问题