2013-07-03 68 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和不用表格。