简体   繁体   English

表格在Firefox中添加了额外的像素

[英]table adds extra pixels in firefox

I just started creating a website for a darts organisation but I'm encountering some problems in my table layout. 我刚刚开始为飞镖组织创建网站,但是我的桌子布局遇到了一些问题。

I made a table with a table-layout fixed and 978px width. 我用固定的表格布局和978px的宽度制作了一张表格。 When I take a look in firefox it somehow for unknown reason always adds another 8px. 当我看一下Firefox时,由于某种未知的原因,它总是会增加另一个8px。 In safari everything works perfect. 在野生动物园中,一切正常。 I have no idea what is happening here. 我不知道这里发生了什么。

I made the web with the problem available on the link below. 我通过以下链接在网上提供了该问题。 Any suggestions is welcome. 任何建议都欢迎。

 .dt { margin: 0px; border-width: 0px; border-spacing: 5px; border-collapse: separate; table-layout: fixed; } .dt th { border-bottom: 1px solid #cdcdcd; color: #5197fc; font-weight: bold; font-size: 12px; } .dt td { border-bottom: 1px dotted #cdcdcd; overflow: hidden; white-space: nowrap; } 
 <table runat="server" style="width: 978px;" class="dt"> <tr runat="server"> <th runat="server" class="left" style="width: 511px">Naam</th> <th runat="server" class="left" style="width: 152px">Tel/Gsm</th> <th runat="server" class="left" style="width: 252px">Email</th> <th runat="server" class="left" style="width: 38px"></th> </tr> <tr runat="server"> <td runat="server" style="width: 511px"></td> <td runat="server" style="width: 152px"></td> <td runat="server" style="width: 252px"></td> <td runat="server" style="width: 38px"> <asp:ImageButton runat="server" ID="EditAccount" ImageUrl="~/Images/pencil.png" CommandName="EditAccount" Width="16px" Height="16px" /> <asp:ImageButton runat="server" ID="DeleteAccount" ImageUrl="~/Images/delete.png" CommandName="DeleteAccount" Width="16px" Height="16px" /> </td> </tr> </table> 

Check problem here 在这里检查问题

Type an A in the textbox and press search to see the problem. 在文本框中键入A,然后按搜索以查看问题。

I managed to solve my problem in multiple ways. 我设法通过多种方式解决了我的问题。 I have set border collapse to collapse and adjusted the width of all table cell except the width of the last table cell of each row. 我将边框折叠设置为折叠并调整了所有表格单元的宽度,除了每行最后一个表格单元的宽度。 for some reason firefox doesn't ever give the actuall width of the cells you asked for. 由于某些原因,Firefox无法提供您所需要的单元格的实际宽度。 it always adds or retracts some the width which shows weird behavior. 它总是增加或缩小一些显示奇怪行为的宽度。

Thats why I removed the entire table and switch to div with "display: table". 这就是为什么我删除了整个表并使用“ display:table”切换到div的原因。 This doesn't give me those weird behavior problems. 这不会给我带来那些奇怪的行为问题。

 .dt { display: table; } .tr { display: table-row; } .dt .th { display: table-cell; border-bottom: 1px solid #cdcdcd; color: #5197fc; font-weight: bold; } .dt .td { border-bottom: 1px dotted #cdcdcd; overflow: hidden; white-space: nowrap; } 
  <div class="dt" style="width: 960px"> <div class="tr"> <div class="th" style="width: 500px">Naam</div> <div class="th" style="width: 150px">Tel/Gsm</div> <div class="th" style="width: 250px">Email</div> <div class="th" style="width: 60px">&nbsp;</div> </div> <div class="tr"> <div class="td" style="width: 500px">&nbsp;</div> <div class="td" style="width: 150px">&nbsp;</div> <div class="td" style="width: 250px">&nbsp;</div> <div class="td" style="width: 60px">&nbsp;</div> </div> </div> 

It's because you have border-spacing: 5px; 这是因为您有border-spacing: 5px; on the dt elements. dt元素上。 Decreasing that value should decrease the amount of "extra pixels". 减小该值将减少“额外像素”的数量。

Adding border-collapse: collapse; 增加边界崩溃:崩溃; should fix your problem 应该解决你的问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM