如何创建可打印的Twitter-Bootstrap页面

我正在使用Twitter-Bootstrap,我需要能够按照浏览器上的外观打印页面。我可以打印使用Twitter-Bootstrap制作的其他页面,但是我似乎无法打印仅使用Twitter-Bootstrap的页面。我在某处缺少标签吗?


弑天下
浏览 554回答 3
3回答

心有法竹

确保为打印分配了样式表。它可以是一个单独的样式表:<link rel="stylesheet" type="text/css" media="print" href="print.css">或您为所有设备共享的一个:<link rel="stylesheet" type="text/css" href="bootstrap.min.css"> # Note there's no media attribute然后,您可以使用媒体查询在单独的样式表中或在共享的样式表中为打印机编写样式:@media print {&nbsp; &nbsp; /* Your styles here */}

尚方宝剑之说

@media printcss文件中有一段代码(Bootstrap 3.3.1 [UPDATE:]至3.3.5),这几乎消除了所有样式,因此即使工作正常,您也可以获得相当平淡的打印输出。现在,我不得不求助于剥出@media print从bootstrap.css部分-这我真的不开心,但我的用户希望直接屏幕抓斗所以这必须现在做的事。如果有人知道如何在不更改引导文件的情况下取消它,我将非常感兴趣。这是“令人反感”的代码块,从第192行开始:@media print {&nbsp; *,&nbsp; *:before,enter code here&nbsp; *:after {&nbsp; &nbsp; color: #000 !important;&nbsp; &nbsp; text-shadow: none !important;&nbsp; &nbsp; background: transparent !important;&nbsp; &nbsp; -webkit-box-shadow: none !important;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; box-shadow: none !important;&nbsp; }&nbsp; a,&nbsp; a:visited {&nbsp; &nbsp; text-decoration: underline;&nbsp; }&nbsp; a[href]:after {&nbsp; &nbsp; content: " (" attr(href) ")";&nbsp; }&nbsp; abbr[title]:after {&nbsp; &nbsp; content: " (" attr(title) ")";&nbsp; }&nbsp; a[href^="#"]:after,&nbsp; a[href^="javascript:"]:after {&nbsp; &nbsp; content: "";&nbsp; }&nbsp; pre,&nbsp; blockquote {&nbsp; &nbsp; border: 1px solid #999;&nbsp; &nbsp; page-break-inside: avoid;&nbsp; }&nbsp; thead {&nbsp; &nbsp; display: table-header-group;&nbsp; }&nbsp; tr,&nbsp; img {&nbsp; &nbsp; page-break-inside: avoid;&nbsp; }&nbsp; img {&nbsp; &nbsp; max-width: 100% !important;&nbsp; }&nbsp; p,&nbsp; h2,&nbsp; h3 {&nbsp; &nbsp; orphans: 3;&nbsp; &nbsp; widows: 3;&nbsp; }&nbsp; h2,&nbsp; h3 {&nbsp; &nbsp; page-break-after: avoid;&nbsp; }&nbsp; select {&nbsp; &nbsp; background: #fff !important;&nbsp; }&nbsp; .navbar {&nbsp; &nbsp; display: none;&nbsp; }&nbsp; .btn > .caret,&nbsp; .dropup > .btn > .caret {&nbsp; &nbsp; border-top-color: #000 !important;&nbsp; }&nbsp; .label {&nbsp; &nbsp; border: 1px solid #000;&nbsp; }&nbsp; .table {&nbsp; &nbsp; border-collapse: collapse !important;&nbsp; }&nbsp; .table td,&nbsp; .table th {&nbsp; &nbsp; background-color: #fff !important;&nbsp; }&nbsp; .table-bordered th,&nbsp; .table-bordered td {&nbsp; &nbsp; border: 1px solid #ddd !important;&nbsp; }}
打开App,查看更多内容
随时随地看视频慕课网APP