【问题标题】:Overflow: auto does not work in Firefox溢出:自动在 Firefox 中不起作用
【发布时间】:2026-02-22 21:55:01
【问题描述】:

我有一张桌子。它的<td>overflow: auto

宽度设置为 100px。在 Firefox only 中,超过 100 像素的文本隐藏并替换为滚动条。

当内容超出容器的宽度时,如何隐藏内容并使用滚动条?

http://jsfiddle.net/be6tM/10/

【问题讨论】:

    标签: html css firefox html-table overflow


    【解决方案1】:

    更简单的方法是将其添加到 Html

    <td class="first">
        <div>Don ovonMrLongNameIsMe!!!</div>
    </td>
    

    这是 CSS

    div {
        overflow:auto;    
    }
    
    td {
        border: 1px solid rgb(0,0,0);
        min-width: 100px;
        max-width: 100px;
    }
    

    工作示例:

        div {
            overflow:auto;    
        }
    
        td {
            border: 1px solid rgb(0,0,0);
            min-width: 100px;
            max-width: 100px;
        }
    <table>    
      <tr>
        <td class="first">
            <div>Don ovonMrLongNameIsMe!!!</div>
        </td>
      </tr>
    </table>

    【讨论】:

      【解决方案2】:

      here 的这个问题也许能解决你的问题

      nickb 回答:“尝试将其包装在 &lt;div&gt; 中。我很确定没有为 &lt;td&gt; 元素定义溢出属性,至少在 HTML4 中没有定义。”

      尝试将您的overflow:auto 发送到wrapper,希望对您有所帮助

      pre, div {
          width:100%;
          overflow: auto !important;
      }
      

      工作demo

      【讨论】: