我有一个需要打印的PHP页面。我设法用下面的打印样式表(print.css(删除了打印中不需要的元素。但是,它不会删除浏览器生成的页眉、页码、URL和日期。我正在使用引导程序框架。bootstrap.min.css没有任何"@media print"之类的东西。需要一些更好的CSS想法来实现这一点。非常感谢。
/* Remove unwanted elements */
/* Assign class="noprint" in the HTML. Header and navigation (<div id="header"> and <div id="nav">) */
#header, #nav, .noprint
{
display: none;
}
/* Ensure the content spans the full width */
#container, #container2, #content
{
width: 100%; margin: 0; float: none;
}
/* Change text colour to black (useful for light text on a dark background) */
.lighttext
{
color: #000
}
/* Remove links */
a:link, a:visited, .navbar-link
{
display: none;
}
在chrome这样的浏览器中,当您尝试打印页面时(Ctrl+p(,它将打开一个对话框。在此框中,您必须选择"更多定义"或类似内容,然后取消选中标题选项。其他浏览器,必须有类似的方式。
据我所知,你不能通过css来更改这一点,但当你打开浏览器的打印对话框时,它应该会为你提供一个排除页眉和页脚(即页码和url(的选项。
无法删除浏览器的默认字符串。你可以在InternetExplorer中利用它们提供的"功能"(也称为bug(,但在其他浏览器中你做不到。