2011-10-11 46 views

回答

9

可以通过标记的大小和打印页的页边距与@page CSS rule

/* In CSS, not JavaScript */ 
@page { 
    size: A4 landscape; 
    margin: 42pt 12pt; 
} 

@media print { 
    /* Define print-specific styles here, for example toning down the decoration 
    of hyperlinks and removing the navigation. */ 
    a {color: inherit !important; text-decoration: none !important;} 
    nav {display: none;} 
} 

然而,browser support是斑点 - 除了prince XML,只有IE8 +和Opera支持它。如果您希望跨打印进行精确的跨浏览器控制,请考虑一个(通常是服务器端)PDF输出机制。