How to make an empty div take space

前端 未结 12 1684
广开言路
广开言路 2020-12-12 13:03

This is my 960 grid system case:

ID
12条回答
  •  一向
    一向 (楼主)
    2020-12-12 13:36

    A simple solution for empty floated divs is to add:

    • width (or min-width)
    • min-height

    this way you can keep the float functionality and force it to fill space when empty.

    I use this technique in page layout columns, to keep every column in its position even if the other columns are empty.

    Example:

    .left-column
    {
       width: 200px;
       min-height: 1px;
       float: left;
    }
    
    .right-column
    {
        width: 500px;
        min-height: 1px;
        float: left;
    }
    

提交回复
热议问题