Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 有没有一种方法可以同步html表中的列宽?_Php_Javascript_Html - Fatal编程技术网

Php 有没有一种方法可以同步html表中的列宽?

Php 有没有一种方法可以同步html表中的列宽?,php,javascript,html,Php,Javascript,Html,如果我有这两张桌子: <table> <tr> <td>Small Length Content</td> </tr> </table> <table> <tr> <td>Dynamic Content Goes Here And It's Longer Than The TD Above</td> </t

如果我有这两张桌子:

<table>
    <tr>
        <td>Small Length Content</td>
    </tr>
</table>

<table>
    <tr>
        <td>Dynamic Content Goes Here And It's Longer Than The TD Above</td>
    </tr>
</table>

小长度内容
这里有动态内容,比上面的TD要长
如何使两列具有相同的宽度


我不能合并表格,所以这不是一个选项。我也不能使用固定宽度,因为它的动态内容。有什么想法吗?也许javascript中的某些东西使顶部列与下部表的宽度相匹配?我不是js专家,所以我不知道这是否可能或者如何做到。如果有一种方法可以使用Php来解决它,那么Php也是一个选项。

您可以使用CSS来实现这一点。你必须有更长的内容包装

td{
   width:80%;
}

您可以使用CSS来实现这一点。你必须有更长的内容包装

td{
   width:80%;
}

你能为这个动态内容定义css吗?假设这些表嵌套在一个div中,如下所示:

<div id="content">
  <table>
    <tr>
      <td>Small Length Content</td>
    </tr>
  </table>

  <table>
    <tr>
    <td>Dynamic Content Goes Here And It's Longer Than The TD Above</td>
    </tr>
  </table>
</div>

你能为这个动态内容定义css吗?假设这些表嵌套在一个div中,如下所示:

<div id="content">
  <table>
    <tr>
      <td>Small Length Content</td>
    </tr>
  </table>

  <table>
    <tr>
    <td>Dynamic Content Goes Here And It's Longer Than The TD Above</td>
    </tr>
  </table>
</div>
试一试


小长度内容
这里有动态内容,比上面的TD要长
或者在
td
元素中添加一个要命名的类,并在其他地方定义样式,如外部文件或标题样式


小长度内容
这里有动态内容,比上面的TD要长

或者在
td
元素中添加一个类来命名,并在其他地方定义样式,如外部文件或标题样式

我会在“流动”列上使用基于百分比的宽度,并在必要时使用固定宽度列对其进行缓冲。即:

<table style="width: 100%;">
    <tr>
        <td style="width: 80%;">Small Length Content</td>
    </tr>
</table>

<table style="width: 100%;">
    <tr>
        <td style="width: 80%;">Dynamic Content Goes Here And It's Longer Than The TD Above&lt;/td>
    </tr>
</table>

小长度内容
这里有动态内容,比上面的TD长/TD>

我会在“流动”列上使用基于百分比的宽度,并在必要时使用固定宽度的列对其进行缓冲。即:

<table style="width: 100%;">
    <tr>
        <td style="width: 80%;">Small Length Content</td>
    </tr>
</table>

<table style="width: 100%;">
    <tr>
        <td style="width: 80%;">Dynamic Content Goes Here And It's Longer Than The TD Above&lt;/td>
    </tr>
</table>

小长度内容
这里有动态内容,比上面的TD长/TD>