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 comment
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 comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...