简体   繁体   English

带有3列的html表,最后一列的宽度为灵活宽度。 前两列以25/75%的固定比率共享剩余空间

[英]html table with 3 column, last column width flexible width. The first two columns share the remaining space with a fixed ratio of 25/75%

Last column has a flexible width dependent on the content. 最后一列的宽度取决于内容。 The first two columns share the remaining space with a fixed ratio of 25/75% I worked with: 前两列使用我处理过的固定比例为25/75%的剩余空间:

<colgroup>
    <col width="24%">
    <col width="74%">
    <col width="2%">
</colgroup>

Works on desktop but it doesn't work on mobile devices. 在台式机上工作,但在移动设备上不工作。

I think it may be possible using more then one table as you can see below. 我认为,可以使用一个以上的表,如下所示。 I have made two tables inside one table. 我在一张桌子里面做了两张桌子。 And used different-different table-layout s when I wanted. 并在需要时使用不同的table-layout

 table {width: 100%;} .table-parent {table-layout: auto; background: yellow;} .table-child-1 {table-layout: fixed; background: red;} .table-child-2 {table-layout: auto; background: green;} 
 <table class="table-parent"> <tr> <td valign="top"> <table class="table-child-1"> <tr> <td bgcolor="pink" width="25%"> First Column </td> <td bgcolor="purple" width="75%"> Second Column </td> </tr> </table> </td> <td> <table class="table-child-2"> <tr> <td> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </td> </tr> </table> </td> </tr> </table> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM