How make middle div to fill space between floating elements?

前端 未结 2 687
温柔的废话
温柔的废话 2020-12-23 20:58

I have three div elements: left, middle and right. Left and right are fixed and floating. What I want is the middle div to fill the gap in between them.

2条回答
  •  不思量自难忘°
    2020-12-23 21:47

    The key is to restructure your html to have middle last, remove the float from the middle and replace it with overflow: hidden.

    View fiddle example.

    HTML

    left
    middle

    CSS

    #left {
        width: 200px;
        float: left;
    }
    #middle {
        overflow: hidden;
    }
    #right {
        width: 200px;
        float: right;
    }
    

提交回复
热议问题