css - Twitter Bootstrap 在一页上打印一长列

标签 css twitter-bootstrap printing

使用 Bootstrap v3.3.7 我有一个包含两列的页面。当我打印此页时,我只想打印一栏,但我希望它适合一张 A4 纸。

<div class="col-xs-4">
    <!-- long list of input fields content goes here -->
    <div class="form-group">
        <label for="firstname">First name</label>
        <input class="form-control input-sm" name="firstname" type="text" value="" id="firstname">
    </div>
    <div class="form-group">
        <label for="lastname">Last name</label>
        <input class="form-control input-sm" name="lastname" type="text" value="" id="lastname">
    </div>
    <!-- about 20 more input fields go here -->
</div>

<div class="col-xs-8 hidden-print">
    <!-- Some content that will not get printed -->
</div>

我只打印第一列(第二列将在打印时隐藏),但因为它很长,所以它跨越了两个打印页面。我想把它放在一页上,因为我有页面的右半部分是空闲的,我想我可以把左栏分成两列,这样它就可以放在一页上。

仅使用 CSS 是否可行,或者我必须更改我的 HTML 以仅用于打印?

最佳答案

Boostrap 很棒!
我刚刚找到了解决方案。在我的例子中,将 col-md-* 用于桌面屏幕,将 col-xs-* 用于小屏幕和打印。

<div class="col-xs-12 col-md-4">
    <div class="col-xs-6 col-md-12">
        <!-- long list of input fields content goes here -->
        <div class="form-group">
            <label for="firstname">First name</label>
            <input class="form-control input-sm" name="firstname" type="text" value="" id="firstname">
        </div>
    </div>
    <!-- this is where on desktop I still have one column but on print (small screen) I break into two 50% columns -->
    <div class="col-xs-6 col-md-12">
        <div class="form-group">
            <label for="lastname">Last name</label>
            <input class="form-control input-sm" name="lastname" type="text" value="" id="lastname">
        </div>
    </div>
</div>

<div class="col-xs-8 hidden-print">
    <!-- Some content that will not get printed -->
</div>

关于css - Twitter Bootstrap 在一页上打印一长列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39869638/

相关文章:

html - Bootstrap slider 向右显示图像

javascript - 我如何在 React 的 props 中应用 css 样式?

python - 如何将大列表拆分成行?

css - 打印模态弹出窗口的内容

javascript - 当横幅图像存储在 javascript 中时,如何将不同大小的相同图像添加到我的媒体查询中的主页横幅?

jquery - 悬停在 div 上的效果同时悬停在整个标签上

html - 使用 Bootstrap 是不好的做法吗?

twitter-bootstrap - Bootstrap 工具提示 data-container=body 并限制 .tooltip-inner 上 css 的范围

javascript - 为什么 .active() 不能使用 typeahead

java - Android - 打印收据到蓝牙打印机