Child div in parent div, float:left

前端 未结 3 941
孤街浪徒
孤街浪徒 2020-12-18 08:10

Please take a look at my code: http://jsfiddle.net/XptrZ/ Why are\'nt the blue divs inside the red one, and why the red one has height=0. How can I solve this? Thanks

3条回答
  •  眼角桃花
    2020-12-18 08:23

    add overflow: hidden to parent

    .parent {
      background-color: gold;
      border: 1px solid gold;
      position: relative;
      overflow: hidden
    }
    
    .child {
      float: left;
      width: 100px;
      height: 100px;
      display: block;
      margin: 10px;
      background-color: pink;
      border: 1px solid #999;
    }
    div1
    div2
    div3

提交回复
热议问题