【发布时间】:2016-10-25 05:56:21
【问题描述】:
我正在经历一些非常奇怪的事情。我正在开发一个聊天系统,其中包含基于表格的行和内容,但格式一直很混乱。我想知道为什么,直到我查看了不工作的源部分,它看起来像这样:
<table border="0">
<tbody>
<tr class="chatline" style="background:white;border-style:none;border-top:1px solid grey;padding:0px;">
<td style="background:#A0D7FF;margin:0px;width:1%;"><span style="padding:2px;background:#A0D7FF;color:black;height:100%;border-right:1px solid grey;">kpsuperplane</span></td>
<td style="color:black;background:white;"><span style="color:black;padding:2px;">test</span></td>
</tr>
<tr class="chatline" style="background:white;border-style:none;border-top:1px solid grey;padding:0px;">
<td style="background:#A0D7FF;margin:0px;width:1%;"><span style="padding:2px;background:#A0D7FF;color:black;height:100%;border-right:1px solid grey;">kpsuperplane</span></td>
<td style="color:black;background:white;"><span style="color:black;padding:2px;">test</span></td>
</tr>
</tbody>
</table>
但是,当我通过 chrome 中的开发工具查看它时,我得到了这个:
<table border="0">
<tbody>
<span style="padding:2px;background:#A0D7FF;color:black;height:100%;border-right:1px solid grey;">kpsuperplane</span>
<span style="color:black;padding:2px;">test</span>
<span style="padding:2px;background:#A0D7FF;color:black;height:100%;border-right:1px solid grey;">kpsuperplane</span>
<span style="color:black;padding:2px;">test</span>
</tbody>
</table>
知道为什么会这样吗? td 和 tr 在呈现时会自动从文档中删除。这不是特定于 chrome 的。 Dreamweaver 中的实时代码给出了同样令人费解的结果。 下图:
【问题讨论】:
-
你能在某处复制它吗.. jsfiddle 会很好..
-
不能。数据是通过 php 从数据库中加载的
-
也尝试给它一个文档类型并渲染它validator.w3.org/docs/help.html#faq-doctype
-
但是您可以在 jsfiddle 上托管标记吗?
-
没关系。这里的js小提琴:jsfiddle.net/NVa2S
标签: html html-table tablerow