Word-wrap in an HTML table

后端 未结 25 3232
温柔的废话
温柔的废话 2020-11-22 02:45

I\'ve been using word-wrap: break-word to wrap text in divs and spans. However, it doesn\'t seem to work in table cells. I have a tabl

25条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-22 03:26

    Turns out there's no good way of doing this. The closest I came is adding "overflow:hidden;" to the div around the table and losing the text. The real solution seems to be to ditch table though. Using divs and relative positioning I was able to achieve the same effect, minus the legacy of

    2015 UPDATE: This is for those like me who want this answer. After 6 years, this works, thanks to all the contributors.

    * { // this works for all but td
      word-wrap:break-word;
    }
    
    table { // this somehow makes it work for td
      table-layout:fixed;
      width:100%;
    }
    

    提交回复
    热议问题