Boostrap@media打印,我可以打印桌面版本吗?覆盖 XS



我已经尝试了我读过的所有可能性,但不起作用。我想使用像桌面版本这样的引导程序(不是xs媒体查询)打印HTML。

可能吗?

在我的代码中,我隐藏了 xs 的一列,但我想打印所有表格。

索引.html

<table class="table table-striped printable">
        <tr>
          <td>Mark</td>
          <td>Otto</td>
          <td>@mdo</td>
        </tr>
        <tr>
          <td>Jacob</td>
          <td>Thornton</td>
          <td>@fat</td>
        </tr>
        <tr>
          <td>Larry</td>
          <td>the Bird</td>
          <td>@twitter</td>
        </tr>    
</table>

主题无

.printable
{
  color: red;
  margin-top:40px;
  tr{
    td{
      color:blue;
      .make-xs-column(6);
      .make-sm-column(4);
      .make-md-column(8);
      .make-lg-column(8);
      .visible-xs();
      .visible-sm();
      .visible-md();
      .visible-lg();
    }
    td + td{
      color:green;
      .make-sm-column(4);
      .make-md-column(2);
      .make-lg-column(2);
      .hidden-xs();
      .visible-sm();
      .visible-md();
      .visible-lg();
    }
    td + td + td
    {
      color:orange;
      .make-xs-column(6);
      .make-sm-column(4);
      .make-md-column(2);
      .make-lg-column(2);
      .visible-xs();
      .visible-sm();
      .visible-md();
      .visible-lg();
    }
  }
}

打印.无

.container {
        max-width: none!important;
        width: 100%!important;
        padding-left: 0;
        padding-right: 0;
    }
    .row {
        margin-left: -1%;
        margin-left: -1%;
    }
    [class*="col-"] {
        float: left;
        padding-left: 1%;
        padding-right: 1%;
    }
    .col-xs-12,
    .col-sm-12,
    .col-md-12,
    .col-lg-12 {
        width: 100%
    }
    .col-xs-11,
    .col-sm-11,
    .col-md-11,
    .col-lg-11 {
        width: 91.66666667%
    }
    .col-xs-10,
    .col-sm-10,
    .col-md-10,
    .col-lg-10 {
        width: 83.33333333%
    }
    .col-xs-9,
    .col-sm-9,
    .col-md-9,
    .col-lg-9 {
        width: 75%
    }
    .col-xs-8,
    .col-sm-8,
    .col-md-8,
    .col-lg-8 {
        width: 66.66666667%
    }
    .col-xs-7,
    .col-sm-7,
    .col-md-7,
    .col-lg-7 {
        width: 58.33333333%
    }
    .col-xs-6,
    .col-sm-6,
    .col-md-6,
    .col-lg-6 {
        width: 50%
    }
    .col-xs-5,
    .col-sm-5,
    .col-md-5,
    .col-lg-5 {
        width: 41.66666667%
    }
    .col-xs-4,
    .col-sm-4,
    .col-md-4,
    .col-lg-4 {
        width: 33.33333333%
    }
    .col-xs-3,
    .col-sm-3,
    .col-md-3,
    .col-lg-3 {
        width: 25%
    }
    .col-xs-2,
    .col-sm-2,
    .col-md-2,
    .col-lg-2 {
        width: 16.66666667%
    }
    .col-xs-1,
    .col-sm-1,
    .col-md-1,
    .col-lg-1 {
        width: 8.33333333%
    }

提前谢谢你。

你可以试试这个:

@media print { 
  .printable {
    tr {
      td + td {
        .visible-xs();
      }
    }
  }
}

关于 -

使用像桌面版本这样的引导程序打印 HTML(不是 xs 媒体) 查询)。

您可以为所需的每个列大小覆盖引导 XS,仅用于打印。

添加到您上一个 css 文件 -

例如,如果您那列 xs-12 将是 md-6 的一半,然后添加

@media print {
    .col-xs-12 {
        width: 50% !important;
    }
}

希望我有帮助。

最新更新