html – 在一个表中右对齐一列并左对齐另一列

前端之家收集整理的这篇文章主要介绍了html – 在一个表中右对齐一列并左对齐另一列前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我创建了一个包含2列的html表.我希望包含文本的第一列右对齐,但我希望第二列保持左对齐,因为它包含复选框.对于演示它看起来,但我不知道.我试过创建一个td class =“column1”然后text-align:right;在CSS但没有运气.

任何想法将不胜感激.

HTML

  1. <td class="column1">Retrieve Logs:</td>
  2. <td class="column2"><input type=checkBox name="getcamlogs" checked="checked"></td>

CSS

  1. td.column1 {
  2. text-align: right;
  3. }

解决方法

你去,这应该工作:)
  1. <style>
  2. #mytable {width:500px; margin:0 auto;}
  3. #mytable td {width:250px;}
  4. #mytable .left {text-align:right; background:#333;}
  5. #mytable .right {text-align:left; background:#666;}
  6. </style>
  7.  
  8. <table id="mytable">
  9. <tr>
  10. <td class="left">1</td>
  11. <td class="right">2</td>
  12. </tr>
  13. </table>

猜你在找的HTML相关文章