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</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</td>
</tr>
</table>
小长度内容
这里有动态内容,比上面的TD长/TD>