Jump to content

Controlling a Column Width

Recommended Posts

Hi there,

  I have been trying set a width of the last column in a table to 200px. 

<div class="table">
  <div class="table-row">
     <div class="table-cell">data</div>
     <div class="table-cell">data</div>
    <div class="table-cell"><span>data</span></div>
.table{display: table;}
.table-row{display: table-row;}
.table-cell{display: table-cell;}
.table-cell span{width: 200px;}

Setting .table-cell:last-child to 200px causes strange behaviour with the height of the cells (this matters as a certain row is highlighted).

Setting a width on the span solves the cell height issue, but the table still distributes the available space to each column evenly, so the last column is its natural width, plus 200px making it pretty wide.

Is there a way to stop this last column filling out and remaining at 200px?


Link to post
Share on other sites

Thanks for this, I found adding the width directly to the cell class caused cell height to play up sometimes though. Is there any way of telling a cell to collapse around an element with a fixed width inside it or does this sort of thing not exist?


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...