html - 奇怪的 CSS 定位行为

标签 html css html-table position alignment

我完全无法理解为什么这个 div 中的表格向右对齐得如此糟糕。

<div id="proof_check" style="position:relative; width:577px;  padding:10px; padding-bottom:0px;padding-top:0px; border:3px solid #ccc;  background-color:#fff; z-index:0"> 
<table><tr><td></td><td style='vertical-align:top; padding-left:5px;'><span style='font-weight:bold; color: #295BA7;'>Proof Approval</span><br /></td></tr><tr><td><input type='checkbox' id='proof-approved'></td><td style='vertical-align:top;padding-left:5px;'>I approve of the above design, spelling and layout and understand that my document will print as it appears above and that after placing my order, it cannot be changed.</td></tr><tr valign=bottom><td colspan='2'></td>
</tr>
</table>
</div>

结果是这样的:

enter image description here

到底为什么要从 div 的中间开始而不是从左边开始呢?

最佳答案

您还没有为表格的“td”列提供任何 colspan 或宽度。因此它将表行“tr”分成两个相等的部分。

给出一个 colspan 元素,例如:

<TABLE STYLE="table-layout:fixed;">
  <COLSPAN>
   <COL width="5%"/>
   <COL width="95%">
  </COLSPAN>
  ....rest of the code goes here...
</TABLE>

每次第一列占 5%,第二列占 95% 宽度。

希望对你有帮助

关于html - 奇怪的 CSS 定位行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17446023/

相关文章:

javascript - 如何使用 CSS 样式将 HTML 表格打印或导出为 PDF,同时保持页面大小(与设备无关)?

html - 如何禁用 IE 中模式对话框的缓存?

html - CSS:将背景图像添加到:具有淡入淡出效果的伪元素之后

css - 特定区域的超链接

html - 表格宽度问题,html css

html - 无法对齐 bootstrap html 代码中的 div

css - Bootstrap/基础列问题

javascript - 使用 Javascript 的正确悬停效果

html - Bootstrap 如何更改表格中链接的样式?

jQuery 在 tr 上应用边框不起作用