How can I get the contents of a div to print in the center of a 8.5x11 sheet of paper?

I pass the information into a div and I have a jQuery print element to print this div. But paper is always printed out of center. How can I design a div to print in the center of the page? is there an appropriate height / width?

This is my css div class

.contract { align: 0 auto; text-align: center; width: 800px; background-color: #fff; clear: both; display: block; } 
+4
source share
2 answers

Use this CSS

 @media print { #printDiv{ position:absolute; width:300px; height:300px; z-index:15; top:50%; left:50%; margin:-150px 0 0 -150px; } } 

The field value must be 50% of the width and height value

+2
source

no css align property. try margin:0 auto; however, without seeing the rest of your document, it is completely impossible to say.

0
source

All Articles