gpt4 book ai didi

css - 在纸上打印时,Twitter Bootstrap 无法正确呈现布局

转载 作者:行者123 更新时间:2023-11-28 15:24:05 26 4
gpt4 key购买 nike

我正在尝试设计一个可用于使用 Twitter Bootstrap 进行打印的网站模板。我当前的代码如下所示

<!DOCTYPE html>
<html>

<head>
<title>Loan</title>
<link rel="stylesheet" href="bootstrap.min.css">
</head>

<body>

<div class="container">
<header>
<div class="col-sm-12">
<div class="row">
<div class="col-sm-3">
<div style="text-align: left;">
<img src="logo-small.png" style="margin-top: 23px;">
</div>
</div>
<div class="col-sm-6 text-center">
<h4>Kingdom of Cambodia <br>Nation Religion King</h4>
<div style="text-align: center;"><img src="lineheader.png" /></div>
</div>
<div class="col-sm-3">
<div style="margin-left: -30px; margin-top: 95px; text-align:right;">Contract number÷ 123456789</div>
</div>
</div>
<!-- end row -->
<div class="row">
<div class="col-sm-12 text-center">
<h4>Letter Approval</h4>
</div>
</div>
</div>
<!-- end col-sm-12 -->
<div style="clear: both; height: 0px;"></div>
<div class=""></div>
</header>
<section>
<div class="col-sm-12">
<p>
&nbsp;&nbsp;&nbsp; Microfinance Institution Plc. Has fulfilled the following terms and conditions: ÷
<p>
Khchei name John Michael Gender Male Nationality Cambodian, Cambodian identification number 123456789 and khchei Michael Alla Gender Female Cambodian Cambodian citizenship identification number 0938475626512 , address, current No. 12Eo, Str. 128, Sangkat Beoung Kang Kong II, Phnom Penh
</p>
<div class="row">
<div class="col-sm-2 col-sm-offset-1">
Phone Number::
</div>
<div class="col-sm-5">
<b>012 9999 2222</b>
</div>
</div>
<div class="row">
<div class="col-sm-2 col-sm-offset-1">
Approval loan amount:
</div>
<div class="col-sm-5">
<b>12,000.00 USD</b>
</div>
</div>
<div class="row">
<div class="col-sm-2 col-sm-offset-1">
For the duration:
</div>
<div class="col-sm-5">
<b>36 months</b>
</div>
</div>
<div class="row">
<div class="col-sm-2 col-sm-offset-1">
For use in order:
</div>
<div class="col-sm-5">
<b>Home Loan</b>
</div>
</div>
<div class="row">
<div class="col-sm-2 col-sm-offset-1">
Interest rate per month:
</div>
<div class="col-sm-5">
<b>1.6% %</b>
</div>
</div>
<div class="row">
<div class="col-sm-2 col-sm-offset-1">
Monthly Payment:
</div>
<div class="col-sm-5">
<b>300.00 USD</b>
</div>
</div>
<div class="row">
<div class="col-sm-2 col-sm-offset-1">
Reward:
</div>
<div class="col-sm-5">
<b>123.345$</b>
</div>
</div>
<div class="row">
<div class="col-sm-2 col-sm-offset-1">
Assurances:
</div>
<div class="col-sm-5">
<b>Hard title</b>
</div>
</div>
<p>
&nbsp;&nbsp;&nbsp;Microfinance Plc reserves the right to amend or terminate this loan at any time if an institution receives information that may cause it to be affected by the basis of which the loan is approved.
</p>
</div>
</section>
</div>
<script src="jquery-1.11.1.min.js"></script>
<script src="bootstrap.min.js"></script>
</body>
</html>

它在浏览器上看起来不错,但是当我打印预览或在 A4 纸上打印时,它的布局与浏览器不一样。

在浏览器上看起来像这样: Layout on browser

当我打印预览或打印 A4 纸时,它看起来很不一样: Layout on printed paper

不知道怎么回事。也许我缺少一种风格?

最佳答案

Bootstrap 是“移动优先”的。这意味着当某些内容不受支持时,它默认为移动布局。当您尝试打印时,我有一种感觉正在发生这种情况。例如,如果您将列类更改为 col-xs-2 而不是 col-sm-2 这应该告诉浏览器将其呈现为 2 列跨度甚至在移动设备上。这应该意味着它将在打印时默认为此。通过使用 sm 而不是 xs 你在小屏幕上说,但不是最小的(移动)屏幕,使用 2 列跨度,否则让它占据整个默认宽度。

本质上它是在打印移动 View ,因此您需要更改“移动”布局。您可以阅读一些相关信息 here .

旁注:如果您想在保留移动布局的同时还支持打印,我唯一能想到的就是将 @media print{... 部分添加到您自己的自定义 css 文件并手动完成,但我想这有点多了。或者,您可以将 bootstrap 在他们的 sm 媒体查询中的内容复制到其中,然后从那里开始。

关于css - 在纸上打印时,Twitter Bootstrap 无法正确呈现布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45596802/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com