1

I have a table cell that I want to hide overflow text over 100px in width. It's here, but it still shows overflow text: http://jsfiddle.net/tkatcqwe/

.text {
  width: 100px;
  background: yellow; 
  white-space: nowrap;
  overflow: hidden;
  position: relative;
}
<table><tr><td class='text'>a really long text about random things, blah blah blah blah blah blah blah</td></tr></table>

0

2 Answers 2

3

.text {
  max-width: 100px;
  width: 100px;
  background: yellow; 
  white-space: nowrap;
  overflow: hidden;
  position: relative;
}
<table><tr><td class='text'>a really long text about random things, blah blah blah blah blah blah blah</td></tr></table>

try adding a max-width of 100px to your .text
added snippet.

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

Comments

1

Wrap the text into a <div> or any block level element, or a <span> + display:block if you want to keep the table untouched.

.text {
    width: 100px;
    background: yellow;
    white-space: nowrap;
    overflow: hidden;
}
<table><tr><td><div class='text'>a really long text about random things, blah blah blah blah blah blah blah</div></td></tr></table>

Or set width:100px on the table instead + table-layout:fixed.

table {
    width: 100px;
    table-layout: fixed;
    border-collapse: collapse;
}
.text {
    background: yellow;
    white-space: nowrap;
    overflow: hidden;
}
<table><tr><td class='text'>a really long text about random things, blah blah blah blah blah blah blah</td></tr></table>

Comments

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.