2012-08-29 30 views
0

我在下面有HTML标记。我需要将包含表格的div的大小减半,所以基本上是overflow:hidden,并且只显示包含在指定大小内的div的一部分。不过,包含div的高度属性未应用于表格。如何缩小包含表格的div的大小

<html> 
  <head> 
    <title>Test</title> 
    <meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
    <style type="text/css"> 
     .temp{ 
      height: 20px; 
     } 
    </style> 
  </head> 
  <body> 
    <div class="temp"> 
        <table border="1"> 
      <tr> 
        <td>This is a test.</td> 
        <td>Do you see what I mean?</td> 
        <td>I hate this overflow.</td> 
      </tr> 
    </table> 
    </div> 

  </body> 
</html> 
+1

您的示例生成一行文本。你想让它只显示文本的上半部分吗? –

+0

愚蠢的我......很明显...... – Mayumi

回答

1
.temp{ 
     height: 15px; 
     overflow: hidden; 
    }​ 

如果这就是你想要的,这将削减一半的文本。你确定你的意思不是

  <tr> 
      <td>This is a test.</td> 
      </tr> 
      <tr> 
      <td>Do you see what I mean?</td> 
      </tr> 
      <tr> 
      <td>I hate this overflow.</td> 
      </tr> 

要做3行,然后隐藏一些呢?