简体   繁体   English

当使用百分比时,如何将内部表的大小设置为外部列的大小?

[英]How do I set the inner table size to the size of the outer column when it is using percentage?

My 'anothertablebody' will increase in size depending on what the user enters, it can increase till it exceed the outer table, I don't want it like this. 我的“另一个人”的大小会根据用户输入的内容而增加,它会一直增加到超出外部表为止,我不希望这样。 I want the width to be fixed not by pixels, but according to the outer table. 我希望宽度不是由像素固定,而是根据外部表固定。 For eg col1 I want it 10% of the outer column, col2 30% of the outer column n col3 60% of the outer column... how can it be done? 例如,对于col1,我希望它占外部列的10%,col2占外部列的30%,而col3则占外部列的60%...该怎么做?

It would be good if I can also get what the 100% width in pixel... 如果我还能获得100%的像素宽度,那将是很好的...

<table width='90%'>
<tbody id='todobody'>
    <tr>
        <td valign='top' width='100%'> <--- this is the outer column
            <div class='div1'>
                <table>
                    <tbody id='atablebody'>
                    <tr>
                    <td>col1</td>
                    <td>col2</td>
                    <td>col3</td>                                               
                    </tr>
                    </tbody>
                    <tbody id=anothertablebody'></tbody>
                </table>
            </div>
        </td>
    </tr>
</tbody>
</table>
<table width='90%'>
<tbody id='todobody'>
    <tr>
        <td valign='top' width='100%'> <!-- this is the outer column-->
            <div class='div1' style="width: 100%;">
                <table width="100%">
                    <tbody id='atablebody'>
                    <tr>
                    <td width="10%">col1</td>
                    <td width="30%">col2</td>
                    <td>col3</td>                                               
                    </tr>
                    </tbody>
                    <tbody id=anothertablebody'></tbody>
                </table>
            </div>
        </td>
    </tr>
</tbody>
</table>

When you say width="100%" , it means that particular tag should occupy 100% of the width available to it 当您说width="100%" ,表示特定标签应占据其可用宽度的100%

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

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