html - Bootstrap 打印 View

标签 html css twitter-bootstrap

我正在尝试打印一张我用 HTML 和 Bootstrap CSS 构建的发票。但是,当我尝试打印时,内容不是全宽的。我已将媒体从屏幕 更改为全部

Web Page View:

Print View:

CSS

@media print {
  * {
    text-shadow: none !important;
    color: #000 !important;
    background: transparent !important;
    box-shadow: none !important;
    border-width:0 0px 0px 0 !important;
  }

HTML

<link rel="stylesheet" href="views/css/bootstrap.css" media="all">

最佳答案

我在我的一个应用程序中使用过,希望它能帮助你.. 尝试打印内容如下

HTML

<button class="btn btn-default" onclick="printContent('class or ID of your content')">Print Content</button>

脚本

function printContent(el){
        var restorepage = document.body.innerHTML;
        var printcontent = document.getElementById(el).innerHTML;
        document.body.innerHTML = printcontent;
        window.print();
        document.body.innerHTML = restorepage;
    }

关于html - Bootstrap 打印 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33048130/

相关文章:

java - 如何以编程方式添加 styleDependent 名称?

html - 用第二个样式表覆盖 MailChimp 样式表

javascript - 如何计算 UI-Angular 和 Bootstrap 中的字符数

javascript - JS、Rails、CSS - 将按钮与页面上其他内容的底部对齐

javascript - 单击模态按钮关闭模态和复选框检查已禁用

javascript - 定位滚动条

javascript - 如何以编程方式生成 mousedown 或 keypress 事件?

javascript - 通过预选下拉列表加载 Ajax 下拉列表

javascript - 0 高度 div 的类在 textarea 上应用

animation - 伪类-带css3的动画