How to format CSS for 8.5x11 inch printed pages

邮差的信 提交于 2020-01-12 03:12:10

问题


I am looking for help setting up the initial DIV that will fit within the borders of the letter paper. I'll loop for dynamic page content ending each page with `page-break-after; always;.

I've been using the trial and error approach and have now run out of paper to trial with.

How do you setup the div container where positions relate to the paper margins?

Thank you!


回答1:


After using a CSS reset template, and with "shrink to page" turned off in print options I am able to make a DIV that is 7" (about 670px) wide and 9.5 (about 900px) high. I can position inside this box.

It translates fine between the printers I have connected. If my calculations are correct, the print DPI is about 95ppi.

#printPage
{
  margin: 0px;
  padding: 0px;
  width: 670px; /* width: 7in; */
  height: 900px; /* or height: 9.5in; */
  clear: both;
  background-color: gray;
  page-break-after: always;
}

Then positioning like this works:

#cube
{ 
  position: relative;
  top: 1in;
  left: 1in;
  width: 1in;
  height: 1in;
  background-color: white;
}


来源:https://stackoverflow.com/questions/4204675/how-to-format-css-for-8-5x11-inch-printed-pages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!