CSS: Two 50% fluid columns not respecting min width

后端 未结 8 1019
清歌不尽
清歌不尽 2021-01-12 07:35

I\'m trying to use this layout with two 50% column width instead. But it seems that when the right columns reaches its \'min-width\', it goes under the left column. Is there

相关标签:
8条回答
  • 2021-01-12 08:35

    This is a quick attempt but it works (only tested in Firefox):

    <head>
    <style type="text/css">
    
    #left {
        float: left;
        width: 50%;
    }
    
    .minwidth {
        min-width: 500px;
        background:#eee;
        height: 0;
        overflow:visible;
    }
    .col{
        min-width:250px;
        background:#eaa;
    }
    
    </style>
    </head>
    <body>
    <div id="wrapper" class="minwidth">
        <div id="left" class="col">
            left
        </div>
        <div id="right" class="col">
            right
        </div>
        <div><!-- Not needed --></div>
    </div>
    </body>
    
    0 讨论(0)
  • 2021-01-12 08:37

    Use a 2 column table. It will do exactly what you want. Div's are supposed to be used to simply divide up logically distinct blocks, and tables are there to lay out columned data. If you want two columns, use a table, rather than trying to force Div's to behave like a table.

    0 讨论(0)
提交回复
热议问题