【问题标题】:Fixed display of TR/table over DOCTYPE XHTML修复了 TR/table 在 DOCTYPE XHTML 上的显示
【发布时间】:2020-07-17 04:01:49
【问题描述】:

显示相同的代码不同 通过 XHTML () 和 HTML5 ()

<table border="1">
<tr><th>COL1</th><th>COL2</th><th>COL3</th></tr>
<tr><form action="">
<td>111</td><td><input type="text" name="correo" /></td><td>333</td>
</form></tr>
and other TR with other form ...
and other TR with other form ...
and other TR with other form ...
...
</table>

...我需要用 XHTML 显示这个,但是所有的失真...

使用 HTML:

使用 xHTML:

我该如何解决这个问题?

【问题讨论】:

标签: xhtml


【解决方案1】:

样式可以通过使用 HTML5 的 XML 语法(又名 XHTML)来实现

<style>
    tr form { display: contents; }
    td { border: 1px inset black; }
</style>

但不要。您的标记在 HTML 语法或 XML 语法中都不是有效的 HTML5。

您应该使用控件上的form 属性来关联 使用表单进行控制,如下所示:

<form action="" id="myform1"></form>
<table border="1">
  <tr><th>COL1</th><th>COL2</th><th>COL3</th></tr>
  <tr>
    <td>111</td>
    <td><input type="text" name="correo" form="myform1" /></td>
    <td>333</td>
  </tr>
</table>

【讨论】:

  • 亲爱的 Alohci 我需要每个 ROW 一个按钮 [SUBMIT],我不能在 PHP 中使用传统的 var1[]、var2[]... 作为数组。通过这个我需要做一个独立的表格中的每一行。可以通过 xHTML 实现吗?
  • 我不能评论 PHP,但你肯定只需要一个独立的表单 per 每行,而不是 in 每行。比如说,你可以把表格放进去。每行的第一个 td,但它不会改变解决方案。您仍然需要 form 属性将每个控件与其表单的 id 连接起来,当然每个 id 都需要是唯一的。
猜你喜欢
  • 2013-04-08
  • 2011-10-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-12-26
  • 1970-01-01
相关资源
最近更新 更多