Overflow: auto does not work in Firefox

元气小坏坏 提交于 2020-01-11 04:50:06

问题


I have a table. Its <td> have overflow: auto.

The width is set to be 100px. In Firefox only, text that exceeds 100px is not hidden and replaced with a scrollbar.

How can I hide content and have a scrollbar when it exceeds the width of its container?

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


回答1:


this question from here maybe solve your problem

nickb answer: "Try wrapping it in a <div>. I'm pretty sure the overflow attribute is not defined for a <td> element, at least in HTML4 it's not."

try to put your overflow:auto to the wrapper hope this can help you

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

working demo




回答2:


The easier way to do this would be to add this to the Html

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

and this to the CSS

div {
    overflow:auto;    
}

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

Working Example:

    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>


来源:https://stackoverflow.com/questions/16328233/overflow-auto-does-not-work-in-firefox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!