How to fill 100% of remaining height?

后端 未结 8 1061
眼角桃花
眼角桃花 2020-12-04 11:25
+--------------------+
|                    |
|                    |
|                    |
|                    |
|         1          |
|                    |
|            


        
8条回答
  •  借酒劲吻你
    2020-12-04 11:35

    This can be done with tables:

    Then apply css to make someid fill the remaining space:

    #someid {
        height: 100%;
    }
    

    Now, I can just hear the angry shouts from the crowd, "Oh noes, he's using tables! Feed him to the lions!" Please hear me out.

    Unlike the accepted answer which accomplishes nothing aside from making the container div the full height of the page, this solution makes div #2 fill the remaining space as requested in the question. If you need that second div to fill the full height allotted to it, this is currently the only way to do it.

    But feel free to prove me wrong, of course! CSS is always better.

提交回复
热议问题