【问题标题】:Fix the width and height of the table td固定表格td的宽高
【发布时间】:2013-03-03 19:12:21
【问题描述】:

在我的项目中,我正在尝试通过执行以下操作来实现 td 中的 fix the width and height

td{
   max-width:100px;
   max-height:100px;
   width:100px;
   height:100px;
   overflow:hidden;
   word-wrap:break-word;  /* CSS3 */
}

这里是fiddle

但正如您在小提琴中看到的那样,如果 td 中的内容增加,它的高度就会增加。

有办法解决吗?

请给出解决方案,cross-browser

如果 extjs 中有可用的修复程序,那么这也可以帮助我。

PS:我知道using div's很容易实现,但现在我无法更改。

【问题讨论】:

  • 试试fiddle,这可能对你有帮助
  • 感谢您的建议。解除禁令后,我会删除我的答案。

标签: html css extjs cross-browser extjs4.1


【解决方案1】:

我的问题有些不同。我只给了width:100%height:100%table 标签。即,没有固定的td

我通过在每个td 标签内添加div 并给它们固定尺寸来解决这个问题。

td>div{
   /* Giving values less than the td values by assuming */
   width:100px;
   height:100px;
   overflow:hidden;
}

这里是Working Fiddle

感谢@Sowmya 提出这个想法。 :)

PS:我将其发布为答案,以便将来对其他人有所帮助

【讨论】:

    【解决方案2】:

    用 div 包装你的内容

    table{width:500px;height:200px;}
    
    td{border:1px solid green; width:100px;
      height:100px;}
    /* My fix try */
    
    
    td div{
      width:100px;
      height:100px;
      overflow:hidden;
      word-wrap:break-word; 
    }
    

    DEMO

    【讨论】:

    • +1 是的,这是有效的。如果我不知道 td 的宽度和高度,有什么办法可以解决它? (在实际项目中,我只是给了width:100%; height:100%,仅此而已)
    • 至少应该知道身高吧??否则你为什么还要阻止内容流动
    猜你喜欢
    • 2011-10-03
    • 1970-01-01
    • 1970-01-01
    • 2011-10-24
    • 2015-10-09
    • 2014-07-15
    • 2014-06-05
    • 2017-03-13
    • 2012-11-18
    相关资源
    最近更新 更多