0

我在下面有 HTML 标记。我需要将包含表格的 div 的大小减半,所以基本上溢出:隐藏并且只显示包含在指定大小内的 div 的一部分。但是,包含 div 的 height 属性并未应用于表格。

<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>
4

2 回答 2

1

呃-不确定我是否误解了你,只是添加了溢出:隐藏;正在为我做这项工作。看到这个小提琴

于 2012-08-29T19:22:37.223 回答
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行,然后隐藏一些?

于 2012-08-29T19:24:59.270 回答