code_junkie

Using CSS to create table cells of a specific width with no word wrapping

Nov 13th, 2011
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. <style>
  2. table.grid { border: none; border-collapse: collapse; }
  3. table.grid tbody tr td { padding: 1px 2px; }
  4. table.grid tbody tr td div { overflow: hidden; white-space: nowrap; }
  5. table.grid tbody tr td.one { width: 100px; }
  6. table.grid tbody tr td.two { width: 200px; }
  7. </style>
  8. <table class="grid">
  9. <tbody>
  10. <tr>
  11. <td class="one"><div>One</div></td>
  12. <td class="two"><div>Two</div></td>
  13. </tr>
  14. <tr>
  15. <td class="one"><div>Another One</div></td>
  16. <td class="two"><div>Another Two</div></td>
  17. </tr>
  18. </tbody>
  19. </table>
  20.  
  21. <style>
  22. table.grid { border-collapse: collapse; }
  23. table.grid tbody tr td { overflow: hidden; white-space: nowrap; padding: 1px 2px; }
  24. table.grid tbody tr td.one { width: 100px; }
  25. table.grid tbody tr td.two { width: 200px; }
  26. </style>
  27. <table class="grid">
  28. <tbody>
  29. <tr>
  30. <td class="one"><span>One</span></td>
  31. <td class="two"><span>Two</span></td>
  32. </tr>
  33. <tr>
  34. <td class="one"><span>Another One</span></td>
  35. <td class="two"><span>Another Two</span></td>
  36. </tr>
  37. </tbody>
  38. </table>
  39.  
  40. <div class="mainBoxOfTable">
  41. <div class="Line">
  42. <div class="ColumnOne">One</div>
  43. <td class="ColumnTwo">Two</div>
  44. </div>
  45. <div class="Line">
  46. <div class="ColumnOne">another One</div>
  47. <div class="ColumnTwo">another Two</div>
  48. </div>
  49. </div>
Add Comment
Please, Sign In to add comment