Html: 2 td's, how to align them center?
below is the code for Submit and Cancel button. When i have 3 buttons, i aligned the middle one as center. So all the 3 buttons looked good on center. But for something like this, with 2 buttons. How can i align them in the center of tr. With this code it shows on bit left side. Thanks!!
<tr align="center">
<td style="width: 100px; height:开发者_如何转开发 45px;">
<asp:ImageButton ID="imgbtnSubmit" runat="server"
ImageUrl="~/images/submitnew.gif"
OnClick="imgbtnSubmit_Click" ValidationGroup="valCC"
TabIndex="21" />
</td>
<td style="width: 100px; height: 45px;">
<asp:ImageButton ID="imgbtnCancel2" runat="server"
ImageUrl="~/images/cancel.gif"
OnClick="imgbtnCancel2_Click" CausesValidation="false"
ImageAlign="AbsMiddle"
ValidationGroup="valCC" />
</td>
You assign hard widths to both cells. That should force them to the left. If you want things centered, best to leave the sizes off and let the browser figure out what size is best.
Further, Using tables for formating a rookie mistake, as it usually ends up with problems like you're having. Try:
<div style="text-align:center">
<asp:ImageButton ..... />
<asp:ImageButton ..... />
</div>
Put them in one cell (with colspan=2
) and center them there:
<tr>
<td style="width: 200px; height: 45px; text-align: center;" colspan=2>
<asp:ImageButton ID="imgbtnSubmit" runat="server" ImageUrl="~/images/submitnew.gif"
OnClick="imgbtnSubmit_Click" ValidationGroup="valCC" TabIndex="21" />
<asp:ImageButton ID="imgbtnCancel2" runat="server" ImageUrl="~/images/cancel.gif"
OnClick="imgbtnCancel2_Click" CausesValidation="false" ImageAlign="AbsMiddle"
ValidationGroup="valCC" />
</td>
</tr>
精彩评论