DOMPDF table border issue

牧云@^-^@ 提交于 2019-12-05 01:11:29

问题


I've come across a very strange issue with the latest version of DOMPDF (0.6.0 Beta 3). I'm using it to create invoices for customers on my site. The design calls for 1px borders between the table cells. If I use either black or #000 for the border color, the tables are rendered nicely. However, when I change the color, to say #CCC for example, instead of a 1px border, the borders become 2px. I'm using border-collapse:collapse and I've been pulling my hair out over this for 2 days. I'm not changing anything else except the color, yet the border thickness is changing. Has anyone else run across this issue and know what the solution is or have any suggestions? Why does black render a 1px border but other colors are rendered as 2px borders? Help!

Edit: I also have empty cells filled with   as I read that that may cause issues with tables, but still no luck.


回答1:


This might help. I have not tried to reproduce your problem, but I know it helped with some issues I was having with tables. try adding this to your css for the table:

table {
    border-collapse: collapse;
}

Obviously you can use the appropriate selector in the css and not define the entire table class.




回答2:


I've seen some improvement by setting border thickness to 0.01em




回答3:


I was having the exact same problem. It's caused from the table having its own border and the cells having their own borders. Here's how I fixed it:

table {
    border-left: 0.01em solid #ccc;
    border-right: 0;
    border-top: 0.01em solid #ccc;
    border-bottom: 0;
    border-collapse: collapse;
}
table td,
table th {
    border-left: 0;
    border-right: 0.01em solid #ccc;
    border-top: 0;
    border-bottom: 0.01em solid #ccc;
}


来源:https://stackoverflow.com/questions/16782160/dompdf-table-border-issue

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