css floats and its stack order

前端 未结 3 1178
后悔当初
后悔当初 2021-01-18 16:48

I am reviewing the floats property which i learned before,I found a simple issue about floated elements with its own stacking order, the code as:

Example 1:

3条回答
  •  离开以前
    2021-01-18 17:16

    Try this. Just add the overflow:hidden in your css for .box class.

    .box {
      width:100px;
      height:100px;
      overflow:hidden;
    }
    
    .box-1{
      background:teal; 
      float:left;
    }
    .box-2{
      background:blue;
    }
    box-1
    box-2

提交回复
热议问题