Border and values not matching in PDF

Border and values not matching in PDF



This happens when I use display: inline-block to wrap a table. The table itself is in the correct position (shown as pink), but the border is shifted down.



display:inline-block result



Here is the code I used. The three table has the same code, so I removed the other two. And I removed the codes used to setup dompdf


dompdf


<div style="display: inline-block;">
<table class="table-bordered" style="background-color: pink;">
<tbody>
<tr>
<th colspan="2" class="text-left p-2">
<p class="mb-0">
Some Name
</p>
<p class="mb-0">
Some Date
</p>
</th>
</tr>
<tr>
<td class="text-left p-1">
DATA
</td>
<td class="p-1">
VALUE
</td>
</tr>
<tr>
<td class="text-left p-1">
DATA
</td>
<td class="p-1">
VALUE
</td>
</tr>
</tbody>
</table>
</div>



When I use display: inline-table instead, this happens:



display:inline-table result



The table is alright, but it is not in line anymore.



And this is when I used float:left:


float:left



float:left result



In line, but the border seems to moved to the leftmost side as well



I'm doing this because I can't use the grid system of Bootstrap 4 (uses flex), and I need small divs that are inline.


divs



Any idea on possible solutions for this problem or the cause? I want it to be in line and borders properly placed. All of these are showing me the expected result when viewed in the browser, but not in the PDF.





Hi,Can you share the css too?
– Amal
Sep 4 at 10:14





@Amal The classes I used is from Bootstrap 4
– Carl Binalla
Sep 4 at 10:26





Check this jsfiddle.net/0rvjuwh5 How about adding three table inside td's.It work for me here in my html to pdf converter.
– Amal
Sep 4 at 10:31






I'll try rendering it to PDF
– Carl Binalla
Sep 4 at 10:33




1 Answer
1



Hope this helps!



You can add three table's inside each td of another table.


td




<table style="table-layout:fixed;margin:0 auto;">
<tbody>
<tr>
<td style="vertical-align:top;">
<div style="display: inline-block;">
<table class="table-bordered" style="background-color: pink;table-layout: fixed;border-collapse: collapse;">
<tbody>
<tr>
<th colspan="2" class="text-left p-2" style="border: 1px solid #000;">
<p class="mb-0">
Some Name
</p>
<p class="mb-0">
Some Date
</p>
</th>
</tr>
<tr>
<td class="text-left p-1" style="border: 1px solid #000;">
DATA
</td>
<td class="p-1" style="border: 1px solid #000;">
VALUE
</td>
</tr>
<tr>
<td class="text-left p-1" style="border: 1px solid #000;">
DATA
</td>
<td class="p-1" style="border: 1px solid #000;">
VALUE
</td>
</tr>
</tbody>
</table>
</div>
</td>
<td style="vertical-align:top;">
<div style="display: inline-block;">
<table class="table-bordered" style="background-color: pink;table-layout: fixed;border-collapse: collapse;">
<tbody>
<tr>
<th colspan="2" class="text-left p-2" style="border: 1px solid #000;">
<p class="mb-0">
Some Name
</p>
<p class="mb-0">
Some Date
</p>
</th>
</tr>
<tr>
<td class="text-left p-1" style="border: 1px solid #000;">
DATA
</td>
<td class="p-1" style="border: 1px solid #000;">
VALUE
</td>
</tr>
<tr>
<td class="text-left p-1" style="border: 1px solid #000;">
DATA
</td>
<td class="p-1" style="border: 1px solid #000;">
VALUE
</td>
</tr>
</tbody>
</table>
</div>
</td>
<td style="vertical-align:top;">
<div style="display: inline-block;">
<table class="table-bordered" style="background-color: pink;table-layout: fixed;border-collapse: collapse;">
<tbody>
<tr>
<th colspan="2" class="text-left p-2" style="border: 1px solid #000;">
<p class="mb-0">
Some Name
</p>
<p class="mb-0">
Some Date
</p>
</th>
</tr>
<tr>
<td class="text-left p-1" style="border: 1px solid #000;">
DATA
</td>
<td class="p-1" style="border: 1px solid #000;">
VALUE
</td>
</tr>
<tr>
<td class="text-left p-1" style="border: 1px solid #000;">
DATA
</td>
<td class="p-1" style="border: 1px solid #000;">
VALUE
</td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
</tbody>
</table>





It didn't work. Although it is okay in the browser, in the PDF it is not. I had to alter it a bit to make it work.
– Carl Binalla
Sep 5 at 3:35





Ok.So you fixed your issue?
– Amal
Sep 6 at 5:46





Not really, I realized that using a table as a parent is not good because the child tables are dynamic, and the parent table will just go longer and longer in width, surpassing the width of the paper
– Carl Binalla
Sep 6 at 5:48



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Some of your past answers have not been well-received, and you're in danger of being blocked from answering.



Please pay close attention to the following guidance:



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

How do I collapse sections of code in Visual Studio Code for Windows?

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ