question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Collapsed borders not drawn for tables in margin boxes

See original GitHub issue

I made a complex document in it and I’m putting header and footer in @ top-center and @ top-bottom. The problem is that I use a simple 1-row table. On the first page everything is ok, on the second onwards ONLY the border does not work is borderless the rest everything is ok. This only occurs in the header and footer in the rest of the document is ok

First page: image

Second one: image

Code:

<div class="header">
        <table style="border-collapse: collapse; width: 100%; height: 84px;">
            <tbody class="bodyHeader">
                <tr style="height: 21px;">
                    <td style="width: 12.1754%; height: 21px; background-color: cornflowerblue;" rowspan="4">&nbsp;</td>
                    <td style="width: 64.5104%; height: 21px;" rowspan="2">&nbsp;</td>
                    <td style="width: 19.905%; height: 21px;">&nbsp;</td>
                </tr>
                <tr style="height: 21px;">
                    <td style="width: 19.905%; height: 21px;">&nbsp;</td>
                </tr>
                <tr style="height: 21px;">
                    <td style="width: 64.5104%; height: 21px;" rowspan="2">&nbsp;</td>
                    <td style="width: 19.905%; height: 21px;">&nbsp;</td>
                </tr>
                <tr style="height: 21px;">
                    <td style="width: 19.905%; height: 21px;">&nbsp;</td>
                </tr>
            </tbody>
        </table>
        
    </div>
div.header {
            /* display: block; */
            width: 100%;
            position: running(header);
            margin: 0mm;
            padding: 0mm;
        }
        @page iretrato{
            size: A4;
            margin: 2cm;
            margin-top: 3.5cm;

            @top-center {
                vertical-align: top;
                margin: 0mm;
                padding-top: 1cm;
                content: element(header);
                width: 100%;
            }

            @bottom-center {
                content: element(footer);
            }    
        }

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
usameccommented, Sep 9, 2022

The good workaround involves using div tags instead of tables. I.e:

                <div style="display: table">                                                                                  
                    <div style="display: table-row">                                                                                                                        
                        <div style="display: table-cell; padding-right: 20px">A</div>                                         
                        <div style="display: table-cell">A</div>                                                                                                            
                    </div>                                                                                                    
                    <div style="display: table-row">                                                                                                                        
                        <div style="display: table-cell; border-top: 1px solid; padding-right: 20px">BBB</div>                
                        <div style="display: table-cell; border-top: 1px solid">CCCCC</div>                                                                                 
                    </div>                                                                                                                                                  
                </div> 

Divs do not use border-collapse property and do not have this problem.

1reaction
liZecommented, Dec 30, 2020

Ok, i found why this happening, its border-collapse: collapse.

Thanks a lot for taking the time to find this!

I dont know if this is a bug because only shows border on first page but my problem is solved removing this param.

It definitely is, let’s keep this issue open.

Read more comments on GitHub >

github_iconTop Results From Across the Web

border-collapse - CSS: Cascading Style Sheets | MDN
The border-collapse CSS property sets whether cells inside a have shared or separate borders.
Read more >
Simulating border-collapse in lists (no tables) - Stack Overflow
Show activity on this post. Here's how I solved it: add a margin-left/-top of -1px to each li element. Then the borders really...
Read more >
border-collapse | CSS-Tricks
The border-collapse property is for use on <table> elements (or elements made to behave like a table through display: table or display: ...
Read more >
The Box Model of a Collapsed Table Border - Fantasai
The solution is simply to take the difference between the widest collapsed border width and the table's border width and add it to...
Read more >
8 Box model - W3C
The margin, border, and padding can be broken down into top, right, bottom, and left ... other than 'visible') do not collapse with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found