Two columns table : one as small as possible, the other takes the rest

我只是一个虾纸丫 提交于 2019-12-03 04:11:58

Giving the content td a 100% width will force it to take as much space as it can, so .content{ width: 100% } should work.

Also give the .action a white-space: nowrap to make sure the x and the checkmark stay next to each other. Otherwise the content will be able to take even more space and force the icons below each other.

table .action
{
    width:auto;
    text-align:right;
    white-space: nowrap
}
table .content { 
    width: 100% 
}
table 
{
    border-collapse:collapse;
    border-spacing:0;
    width:100%;
    border: 1px solid
}
<table>
  <tbody>
    <tr>
      <td class="action" >
        <a> ✔ </a>
      </td>
      <td class="content">
       <p>Bigger text...(variable size).......</p>
      </td>
    </tr>
    <tr>
      <td class="action" >
        <a> ✔ </a><a> ✘ </a>
      </td>
      <td class="content">
       <p>Bigger text...(variable size).......</p>
      </td>
    </tr>
  </tbody>
</table>
Kirk Douglas Jr

Set the column width: 1px and white-space: nowrap.

This will try to make it 1px, but the nowrap will stop it from getting smaller than the widest element in that column.

samjewell

I found this answer when trying to make one column of many as small as possible.

Giving the content td a 1% width will force it to take as little space as it can, so .content{ width: 1% } worked for me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!