2

I have a table:

    table.tablesorter {
    border: 1px solid #D9D9D9;


}
table.tablesorter thead tr th, table.tablesorter tfoot tr th {
    background-color: #04659D;
    border-bottom: 1px solid #0F5E76;
    border-left: 1px solid #0F5E76;
    font-weight: bold;
    text-align:left;
    padding: 5px 19px 5px 9px;
    color: #fff;
}

Some of the text in the table is too big and is being cut from the page, I have try using word-wrap:break-word; and setting width but nothing its working the text still overflows?

Any tips on how i can fix this?

user3591637
  • 499
  • 5
  • 20

4 Answers4

0

Give your table element a fixed table-layout:

table.tablesorter {
    ...
    table-layout: fixed;
}

From the CSS2.1 specification (linked above):

17.5.2.1 Fixed table layout

With this (fast) algorithm, the horizontal layout of the table does not depend on the contents of the cells; it only depends on the table's width, the width of the columns, and borders or cell spacing.

Community
  • 1
  • 1
James Donnelly
  • 126,410
  • 34
  • 208
  • 218
0

You may want to give this a try: I added the word inside a div and gave it a fixed width plus the word wrap, and it worked for me:

<div id="test">#DecimalFormat(total/counter)#</div>
#test {
    word-wrap:break-word;
    width:40px;
}

Here is your updated jsfiddle

EDITED: While my suggestion works perfectly in the above demo, if it doesn't work in your specific case, you may need to do some cleanup of your code and maybe use !important as a workaround (ie. word-wrap:break-word !important; width:40px !important;), or try adding display:block - that might help too.

benomatis
  • 5,536
  • 7
  • 36
  • 59
0

What is the markup of your table? Perhaps your table's width isn't wide or tall enough to compensate for the auto-adjusting nature of the table cell.

lindsay
  • 972
  • 2
  • 11
  • 21
0

You could add a scrollbar to the cells that have too long words.

just add the following:

table.tablesorter tbody td {
    max-width: 250px;// you can use any width you like, the scrollbar will show up only when a cell exceeds the max-width.
    overflow-x: auto;
}

another option would be to use white-space: normal, see: http://www.w3schools.com/cssref/pr_text_white-space.asp

for example

table.tablesorter tbody td {
    white-space: normal;
}

If this does not work to wrap your text inside a cell, you should check your source and see if there is anything that overwrites your css and fix it.

Andy
  • 2,892
  • 2
  • 26
  • 33