html - Bootstrap 4 网格布局不适用于 dompdf

标签 html css pdf bootstrap-4 dompdf

我正在使用 dompdf 来呈现 PDF 文档。我们在整个应用程序中使用 Bootstrap 4,所以我希望能够在用于生成文档的 twig 模板中使用它。

目前,我面临着 Bootstrap 4 网格系统在生成的 PDF 中无法很好呈现的问题:同一个 .row div 中的元素全部堆积起来。

我确定 Bootstrap CSS 已加载到模板中。

我的代码:

<div class="container-fluid">
    <div class="row">
        <div class="col-xs-1">
            little text
        </div>
        <div class="col-xs-11">
            <h1>Big title</h1>
        </div>
    </div>
</div>

生成的PDF:
screenshot of a pdf with all the text piled up

更新:col-n而不是 col-xs-n
我的代码:

<div class="container-fluid">
    <div class="row">
        <div class="col-1">
            little text
        </div>
        <div class="col-11">
            <h1>Big title</h1>
        </div>
    </div>
</div>

screenshot of a pdf with all the text piled up

最佳答案

试试这门课 .col-1.col-11 , 或 .col-sm-1 .col-sm-11
可用:

.col-   .col-sm-    .col-md-    .col-lg-    .col-xl-

col-xs 用于 bootstrap 3

关于html - Bootstrap 4 网格布局不适用于 dompdf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61616199/

相关文章:

html - 使用 CSS3 动画模仿闪烁标签

html - 列中的九个 div。这个怎么设计?

仅用于打印的 PDF 水印,以编程方式

iphone - iOS 提高 PDF 渲染速度

python - HTML 到 PDF 尺寸不正确

html - 使元素 float 到指定宽度

javascript - 将 Html 表格内容导出到具有自定义文件名的 CSV 文件(应该在 IE 中工作)

javascript - 关于 CSS 媒体查询的问题

javascript - 防止 JQuery .HTML 在显示之前覆盖以前的 .HTML

css - 使用 css 复制 html 元素