如何将表格移到表格的左侧?

马德森

我想将列向左移动,并且也应在两者之间设置一个固定的大小。

现在看起来像这样:http : //i.imgur.com/K1PyTt2.png

希望我能得到这个结果:http : //i.imgur.com/EF2oxhn.png

CSS代码:

.table {
    width:100%;
}

.table table{
    border-collapse: collapse;
    width:100%;
}

.table td{
    padding-left: 5px;
    color: #000000;
    font-size: 12px;
    line-height: 16px;
    margin-bottom: 6px;
    font-family: Arial,Helvetica,sans-serif;
}

.table tr:nth-child(odd){ background-color:#EFEFEF; }
.table tr:nth-child(even)    { background-color:#ffffff; }

.table tr:first-child td{
    padding-left: 5px;
    background-color:#EFEFEF;
    text-align:left;
    color:#868686;
    font-size: 12px;
    font-family: Arial,Helvetica,sans-serif;
    line-height: 16px;
    margin-bottom: 6px;
}

/* Border line in the middle (first-child) Example: 1 | 2 | 3 */
.table tr:first-child td:not(:last-child) { border-right: 1px solid #868686;}

HTML:

<div class="table" >
    <table>
        <tr>
             <td>
               ID#
             </td>
             <td>
               Name
             </td>
             <td>
               Edit
             </td>
              <td>
               Delete
             </td>
       </tr>

<tr><td><?php echo $tags_id ?></td><td><?php echo $name ?></td> <td><?php echo "<a href='edit.php?id=$tags_id'>Edit</a>"; ?></td> <td><?php echo "<a href='delete.php?id=$tags_id'>Delete</a>"; ?></td></tr>

       </table>
</div>

我希望有人能提供帮助,在此先感谢。

普戈茨

您没有告诉我们您使用的是哪个HTML版本,但是以下内容可以在任何版本中使用。添加<colgroup>作为表元素的第一个子元素,如下所示:

<table>
  <colgroup>
    <col width="20em"/>
    <col width="10em"/>
    <col width="10em"/>
  </colgroup>
</table>

这会将列的宽度固定为一定数量的字符。如果这不能满足您的要求,请尝试在<table>上设置width属性,并在您的<col />宽度中使用百分比:

<table width="40%">
  <colgroup>
    <col width="50%"/>
    <col width="25%"/>
    <col width="25%"/>
  </colgroup>
</table>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章