首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >laravel-dompdf |像flex一样将div显示为列

laravel-dompdf |像flex一样将div显示为列
EN

Stack Overflow用户
提问于 2020-01-09 19:01:22
回答 1查看 4.8K关注 0票数 0

我正在创建PDF格式的导出会议详细信息的布局。布局过程中出现问题。我想将div显示为一列。例如,image display: flex不工作,我尝试了表格、表格单元、表格灵活和表格网格,但没有工作。主要内容向下移动侧栏长度。

我所有的刀片html代码;

代码语言:javascript
运行
复制
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link href="https://fonts.googleapis.com/css?family=Roboto:300,500,700&display=swap" rel="stylesheet">
    <style media="screen">
        @font-face {font-family: "Roboto-Light"; font-style: normal; font-weight: 300; src: url({{ url('fonts/Roboto-Light.ttf') }})}
        @font-face {font-family: "Roboto-Regular"; font-style: normal; font-weight: normal; src: url({{ url('fonts/Roboto-Regular.ttf') }})}
        @font-face {font-family: "Roboto-Bold"; font-style: normal; font-weight: bold; src: url({{ url('fonts/Roboto-Bold.ttf') }})}

        body { font-family: 'Roboto-Regular'; }
        * { margin: 0; padding: 0; }

        .sidebar {
            position: relative;
            left: 0.9cm;
            width: 5cm;
        }

        .page-break-after {
            page-break-after: auto;
        }

        body {
            padding-top: 3cm;
            padding-bottom: 100px;
        }

        .wrapper {
            position:relative;
            width: 21cm;
            display: table;
        }
    </style>
</head>
<body style="background: url({{ url('pdf-export-background.png') }});background-size: 100% 100%;">

    <div class="wrapper">
        <div class="sidebar" style="">
            <p style="text-align:center;font-size:8px;">{{ $meeting['place'] }}</p>

            <!-- List Item -->
            <p style="margin-top: 15px;">
                <h4 style="margin-left:5%;font-family:'Roboto-Bold' !important;font-size:10px;">
                    <span style="border-bottom: 1px solid #000;">Düzenleyen</span>
                </h4>
                <p style="padding-left: 5%;">
                    <span style="font-size:9px;">{{ $meeting['created_user']['name'] }}</span>
                    <span style="font-size:7px;font-weight:300;line-height:9px;">{{ $meeting['job_title_name'] }}</span>
                </p>
            </p>
            <!--#List Item -->

        </div>

        <div style="position: relative;width: 5.7cm;">
            THE MAIN CONTENT
        </div>
    </div>
</body>
</html>
EN

回答 1

Stack Overflow用户

发布于 2020-01-21 09:04:46

在撰写本文时,Dompdf不支持flexbox (当前版本是0.8.4)。有关更多信息,请参阅issue 971

您可以使用各种样式生成该布局,但是如果您的内容超出了页面的长度,就会在Dompdf呈现过程中遇到一些奇怪的问题。我建议将侧边栏向左浮动,并在主要内容上设置左边距。

如下所示:

代码语言:javascript
运行
复制
<div>
  <div style="float: left; width: 25%; height: 80%; background-color: #cc6633;"></div>
  <div style="margin-left: 35%; width: 65%; height: 80%; background-color: #3366cc;"></div>
</div>
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59662484

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档