开发者

Right aligning one column and left aligning the other, within one table

I have created an HTML table with two columns. I want the first column containing text to be right aligned, but I want the second column to stay left aligned as it contains check boxes. For presentation it would look, but I’ve no idea. I have tried creating a td class="column1" and then text-align: right; in the CSS, but no luck.

How can I do it?

HTML开发者_如何学C

<td class="column1">Retrieve Logs:</td>
<td class="column2"><input type=checkbox name="getcamlogs" checked="checked"></td>

CSS

td.column1 {
   text-align: right;
}


Here you go; this should work :)

<style>
    #mytable {width:500px; margin:0 auto;}
    #mytable td {width:250px;}
    #mytable .left {text-align:right; background:#333;}
    #mytable .right {text-align:left; background:#666;}
</style>

<table id="mytable">
    <tr>
        <td class="left">1</td>
        <td class="right">2</td>
    </tr>   
</table>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜