2009-08-25 36 views
-1

我試過把valign =「top」作爲<td>的屬性,但徒勞無益。如何垂直對齊<input>和<iframe>內​​?

<tr> 
<td> 
    <span class="validationInline">*</span> 
    Security Code: 
</td> 
<td valign="top"> 
    <input type="text" /> 
    <iframe scrolling="no" height="21px" frameborder="0" width="62px" marginheight="0" marginwidth="0" src="http://google.com"></iframe> 
</td> 
</tr> 

似乎<input>贊同的BUTTOM,而頂端。

+0

我會把這個清理一下,或者把它變成一個「社區維基」,這樣我們就可以在不重新發布的情況下改進它。 – 2009-08-25 06:07:08

回答

0
<td valign="top"><input type="text" /> 
    <iframe scrolling="no" height="18" frameborder="0" width="62" marginheight="0" marginwidth="0" src="http://google.com"> </iframe></td> 

上面的作品適合我......它將內容與單元格的頂部對齊。這是你在追求什麼?

+0

是的,但不適合我。 – omg 2009-08-25 05:48:34

+0

你使用什麼瀏覽器? – 2009-08-25 05:49:03

+0

Firefox,而在IE中,圖像根本無法顯示。 – omg 2009-08-25 05:50:46

1

從您的描述看來,單元對齊頂部,但輸入/ iframe在底部彼此對齊。垂直對齊通常僅適用於同級元素。

您需要做的是在輸入和iframe上設置CSS vertical-align:top屬性。

<td valign="top"> 
    <input style="vertical-align:top" type="text" /> 
    <iframe style="vertical-align:top" scrolling="no" height="18" frameborder="0" width="62" marginheight="0" marginwidth="0" src="http://google.com"> </iframe> 
</td>