如何格式化8.5x11英寸打印页面的CSS

Chr*_*ris 16 css printing templates

我正在寻找帮助设置适合信纸边界的初始DIV.我将循环使用`page-break-after结束每个页面的动态页面内容; 总是;.

我一直在使用试错法,现在已用完了试用版.

如何设置位置与纸张边距相关的div容器?

谢谢!

Chr*_*ris 21

使用CSS重置模板后,在打印选项中关闭"缩小到页面",我可以制作一个7"(约670像素)宽,9.5(约900像素)高的DIV.我可以放在这个盒子里面.

它在我连接的打印机之间转换得很好.如果我的计算是正确的,则打印DPI约为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;
}
Run Code Online (Sandbox Code Playgroud)

然后像这样的定位工作:

#cube
{ 
  position: relative;
  top: 1in;
  left: 1in;
  width: 1in;
  height: 1in;
  background-color: white;
}
Run Code Online (Sandbox Code Playgroud)