2013-07-03 65 views
0

这完全超出了我为什么div中的表格被严格排列在右边。奇怪的CSS定位行为

<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的中间,而不是在左边的详细首发?

+0

它不适合我 - http://jsfiddle.net/G9Er8/ – Prisoner

+0

请正确格式化您的代码。 – Andri

回答

0

您尚未向表格的'td'列提供任何colspan或宽度。因此它将表格行'tr'分成两个相等的部分。

给像列跨度元件:

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

每次第一列是5%,并且第二占据95%的宽度。

希望帮助

0

代码似乎好一些,我可以做的唯一的问题是“位置:亲属”在你proof_check DIV,也许你的父母DIV引起的问题。 将其更改为“position:absolute” 希望能够解决您的问题!

0

这是因为您没有为您的第一个表格单元格(与检查器框)定义宽度。设置宽度,你应该没问题......或者用div和不用表格。