在Firefox中使用CSS的表格溢出

dru*_*mer 3 css firefox html-table overflow

我无法让我的桌子表现出来.内容不断溢出,我试图限制它并没有产生预期的效果.

这是我的标记:

<div class="repeatingdiv">
 <div class="hastitle">Some title</div>  
 <div class="hastable">
  <table>
   <thead><tr><th></th></tr></thead>     
   <tfoot><tr><th></th></tr></tfoot>
   <tbody>   
    <tr>
     <td class="col1">Col 1</td>
     <td class="col2">Col 2</td>
     <td class="col3">Col 3</td>
    </tr>
   </tbody>
  </table>
 </div>
</div>
Run Code Online (Sandbox Code Playgroud)

然后我有一些风格.该td's四溢,但我没有任何运气设定自己overflow to hidden/auto.我确实在hastable包含该表的类中设置溢出运气更好.但是我仍然无法让Firefox尊重width3列的分布:30%, 35%, 35%.我也尝试过设置min-width,但仍然没有运气.我在页面上有几个这样的表,每个表都有自己的宽度.对这张桌子有什么帮助吗?

.repeatingdiv { }
.hastitle      { margin:0 10px; padding:3px 3px 1px 6px; }       
.hastable      { overflow:hidden; 
                 text-overflow: ellipsis; 
                 margin:10px; 
                 padding:10px; 
               }
table          { }
table tbody    { width: 100%; }
tr    { width: 100%; }
td.col1     { width:30%; min-width:30%; }
td.col2  { width:35%; min-width:35%; }
td.col3  { width:35%; min-width:35%; }
Run Code Online (Sandbox Code Playgroud)

K P*_*ime 9

众所周知,表格很难.尝试将此添加到您的CSS:

table { table-layout: fixed; width: 100% /* or whatever fixed width */; }
Run Code Online (Sandbox Code Playgroud)

我还建议使用实际的HTML COL/ COLGROUP元素来定义列,如下所示:

<table>
 <colgroup class="col1" />
 <colgroup class="col2" />
 <colgroup class="col3" />
 <thead><tr><th></th></tr></thead>     
 <tfoot><tr><th></th></tr></tfoot>
 <tbody>   
  <tr>
   <td>Col 1</td>
   <td>Col 2</td>
   <td>Col 3</td>
  </tr>
 </tbody>
</table>
Run Code Online (Sandbox Code Playgroud)

请注意,尽管如此,具有溢出数据的单元格强制包含单元格,行和表格扩展以适应.CSS overflow: auto/ hidden/ scroll不影响细胞.

参考: