My goal is to keep the tags within the table fixed when printing. The code I've written functions correctly in View mode, however, when printed using JavaScript, if one of the columns is too large, the rest of the columns get displaced. I want all columns to remain aligned at the top. I attempted to use position: fixed but it caused the table layout to crash.
<script>
function printDiv() {
var divToPrint = document.getElementById('table');
var htmlToPrint = '' +
'<style type="text/css">' +
'table th, table td,table tr {' +
'font-family:B Nazanin;'+
'border:0.1em solid #000;' +
'text-align:center;' +
'font-size:14px;' +
'padding:0.2em;' +
'}' +
'</style>';
htmlToPrint += divToPrint.outerHTML;
newWin = window.open("");
newWin.document.write(htmlToPrint);
newWin.print();
newWin.close();
}
</script>