日期:2014-05-17  浏览次数:20623 次

不同元素对齐的问题:需要底部,或者是中间对齐。
HTML code

<table>
    <tr>
        <td>
            <input type="text" style="height:16px; width:27px" id="text1" />
            <input type="image" src="images/logo.gif" style="height:16px; width:16px;" id="image1" />
        </td>
    </tr>
</table>



怎么写样式可以让image1和text1底部对齐(或者中间对齐)??

按照上面的写法,image1的显示位置总会高于text1
(貌似image1的底部是和text1的中间对齐的,如果将两个元素分别放到不同的TD,垂直对齐样式就又起作用了!)。

按照上面的写法,使用CSS怎么设置对齐?

------解决方案--------------------
image1和text1底部对齐:
HTML code

<table>
    <tr>
        <td>
            <input type="text" style="height:16px; width:27px" id="text1" />
            <input type="image" src="images/logo.gif" style="height:16px; width:16px; vertical-align:bottom" id="image1" />
        </td>
    </tr>
</table>

------解决方案--------------------
用css 控制 最终还是会遇到 兼容的问题,还不如改页面的好呢。
HTML code



<table>
    <tr>
        <td>
            <input type="text" style="height:16px; width:27px" id="text1" />
        </td>
        <td>
            <input type="image" src="images/logo.gif" style="height:16px; width:16px;" id="image1" />
        </td>
    </tr>
</table>