I’ve kept a Javascript function printthis()
for printing purpose that prints everything in the div id printthis
except what is given with the class d-print-none
. The code works fine in the opening page, the page before printing.
But upon clicking print, the page takes wrong alignment, means the table head appears in between 2 address divs like in the below link, I wanted the table head to appear after the address blocks like it appears in the page before printing.
How can I fix this? Can I get some help?
https://jsfiddle.net/vwsmf50e/
The full script & css is availble in the above link.
JavaScript
x
47
47
1
<div id="printthis">
2
<div class="container-fluid">
3
<div id="ui-view" data-select2-id="ui-view">
4
<div>
5
<div class="card">
6
<style>
7
</style>
8
9
<div class="card-header">
10
<a class="float-right mr-1 d-print-none" href="#" onclick="printthis()" data-abc="true"><i class="fa fa-print fa-fw" title="Print Invoice"></i></a>
11
</div>
12
</div>
13
<div class="card-body">
14
<div class="row mb-4">
15
<div class="col-sm-8 address2" style="margin-bottom: 0rem!important;">
16
<div><img width='40px' height='40px' src=''> <strong>yyy</strong>
17
<div> kbjk</div>
18
<div>Email: ui</div>
19
<div>Phone: 45546</div>
20
</div>
21
</div>
22
<div class="col-sm-4 ml-auto address">
23
<div><h6></h6></div>
24
<div><strong>xfgfggggggggg</strong></div>
25
<div>tttttttttt</div>
26
<div>lllllllll</div>
27
<div>Email: ac@r.com</div>
28
<div>Phone: 222222</div>
29
</div>
30
31
32
</div>
33
<hr class="d-print-none addrow">
34
35
<table class="table text-centered table-bordered bill-tab">
36
<thead class="table-header h" id="theader">
37
<tr><th class="lefttable-des"><h5>Description</h5></th>
38
<th class="table-des"><h5>Amount</h5></th></tr>
39
</thead>
40
</table>
41
</div>
42
</div>
43
</div>
44
</div>
45
</div>
46
47
Advertisement
Answer
Give width:100% for bill-tab.
JavaScript
1
8
1
.bill-tab {
2
overflow-x: auto;
3
border-spacing: 2px;
4
border: 1px solid #dee2e6;
5
max-width: 100%;
6
width: 100%;
7
}
8