开发者

How do you stop HTML tables from being propped up by the content?

With some HTML like this:

<!DOCTYPE html>
开发者_运维技巧<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
  <style>
    td {
      width:10px;
    }
  </style>
</head>
<body>
  <table>
    <tr><td>Text</td><td>Text</td><td>Text</td><td>Text</td></tr>
    <tr><td>Text</td><td>Text</td><td>Text</td><td>Text</td></tr>
    <tr><td>WHOA I'M A LONG STRING!</td><td>Text</td><td>Text</td><td>Text</td></tr>    
  </table>
</body>
</html>​

The tds don't get a width of 10px, they are just as long as the longest string in them.

How do you make this work?


You can change the css to:

max-width: 10px;
overflow: hidden;

but that will chop off the words mid-letter, wherever the edge happens to be.


I think all you could do is wrap the content in a div and give the div a width and overflow:hidden. It cuts off the text (or content), so that may not be what you're looking for.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜