2

I have an issue I'm trying to solve about table-cell display and its content which make its parent width grow despite of table-cell fixed width and overflow defined.

JSFiddle: http://jsfiddle.net/8cevryh9/

<table border="3">
    <tr>
        <td style="width: 20px">1</td>
        <td style="width: 80px; overflow:hidden;">
            <div style="width:200px">
                FAT CONTENT
            </div>
        </td>
        <td style="width: 30px">3</td>
    </tr>
</table>

Here 2nd cell is 200px width, I would have it stay 80px and the content overflow hidden. Anyone an idea ?

1
  • set a max-width not solve this issue? Commented Dec 22, 2014 at 17:26

1 Answer 1

3

Set a width on the table, as well as the table-layout to fixed:

table {
  table-layout: fixed;
  width: 130px;
}
<table border="3">
  <tr>
    <td style="width: 20px">1</td>
    <td style="width: 80px; overflow:hidden;">
      <div style="width:200px">
        FAT CONTENT
      </div>
    </td>
    <td style="width: 30px">3</td>
  </tr>
</table>

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much ! Didn't know this style attribute table-layout.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.