zoukankan      html  css  js  c++  java
  • Bootstrap打印问题

    删除bootstrap的样式引用,就可以正常打印预览了。

    bootstrap 设置了@media print相关属性导致

    @media print {
      * {
        color: #000 !important;
        text-shadow: none !important;
        background: transparent !important;
        box-shadow: none !important;
      }
      a,
      a:visited {
        text-decoration: underline;
      }
      a[href]:after {
        content: " (" attr(href) ")";
      }
      abbr[title]:after {
        content: " (" attr(title) ")";
      }
      a[href^="javascript:"]:after,
      a[href^="#"]:after {
        content: "";
      }
      pre,
      blockquote {
        border: 1px solid #999;
    
        page-break-inside: avoid;
      }
      thead {
        display: table-header-group;
      }
      tr,
      img {
        page-break-inside: avoid;
      }
      img {
        max-width: 100% !important;
      }
      p,
      h2,
      h3 {
        orphans: 3;
        widows: 3;
      }
      h2,
      h3 {
        page-break-after: avoid;
      }
      select {
        background: #fff !important;
      }
      .navbar {
        display: none;
      }
      .table td,
      .table th {
        background-color: #fff !important;
      }
      .btn > .caret,
      .dropup > .btn > .caret {
        border-top-color: #000 !important;
      }
      .label {
        border: 1px solid #000;
      }
      .table {
        border-collapse: collapse !important;
      }
      .table-bordered th,
      .table-bordered td {
        border: 1px solid #ddd !important;
      }
    }

    代码里面的 color:#000 !important; 以及 。它表示打印时,页面中的文字都为黑色,并且背景色都设置为透明。因为有了这样的样式,我们的背景色就打印

    不出来了。去掉这两段代码。

    值得一提的说:如果页面中有超链接,打印时会显示超链接的地址,这样比较难看。我们删除对应的样式即可。

  • 相关阅读:
    HTTP request smuggling
    Do you really know CSS linear-gradients?
    Populating the page: how browsers work
    船舶智能管理系统API文档
    DocGuarder
    BUC LNB 器件
    BUC 与 LNB 的区别
    EIRP G/T 的意义
    语音的频率、频率分辨率、采样频率、采样点数、量化、增益
    机械波、电磁波的异同
  • 原文地址:https://www.cnblogs.com/kennyliu/p/5006461.html
Copyright © 2011-2022 走看看