想要将 Table 替换为 Div

Want to Replace Table with Div

我在将 HTML 打印到 Mpdf 时遇到问题,因此,我想将 Main Table 转换为 Div,以便在 MPDF 中工作。

我需要使用 div

的相同布局

目前使用 Table

    <style>
        .mainTable {
            background-color: #DEDBDE;
            width: 100%;
        }
        .TdDesign {
            background-color: #F9F9F9;
            color: #000000;
            font-size: 11px;
            padding-left: 5px;
        }
        .MainTD {
            background-color: #EDEDED;
            color: #000000;
            font-size: 11px;
            font-weight: bold;
            padding: 5px;
        }
        </style>
        <table class="mainTable" cellspacing="1" cellpadding="3" border="0">
                            <tbody>
         <tr>
                            <td class="MainTD">Leave</td>
                            <td colspan="3" class="TdDesign">
                                    <table id="supplier" class="mainTable" cellspacing="1" cellpadding="3" border="0">
                                        <tbody><tr>
                                        <td class="TdDesign" width="5%" align="center"><strong>No</strong></td>
                                        <td class="TdDesign" width="10%" align="center"><strong>Type</strong></td>
                                        <td class="TdDesign" width="10%" align="center"><strong>Date</strong></td>
                                        <td class="TdDesign" width="10%" align="center"><strong>From Date</strong></td>
                                        <td class="TdDesign" width="10%" align="center"><strong>To Date</strong></td>
                                        <td class="TdDesign" width="10%" align="center"><strong>Status</strong></td>
                                        </tr></tbody></table>
                            </td>
                            </tr>
        </table>

输出:

我需要与上面相同的输出,但使用这个 div,我试过但没有用

         <style>
    .mainTable {
        background-color: #DEDBDE;
        width: 100%;
    }
    .TdDesign {
        background-color: #F9F9F9;
        color: #000000;
        font-size: 11px;
        padding-left: 5px;
    }
    .MainTD {
        background-color: #EDEDED;
        color: #000000;
        font-size: 11px;
        font-weight: bold;
        padding: 5px;
    }
    </style>    
        <div class="mainTable" cellspacing="1" cellpadding="3" border="0">
                            <div class="MainTD">Leave
                            <div class="TdDesign">
                                    <table id="supplier" class="mainTable" cellspacing="1" cellpadding="3" border="0">
                                        <tbody><tr>
                                        <td class="TdDesign" width="5%" align="center"><strong>No</strong></td>
                                        <td class="TdDesign" width="10%" align="center"><strong>Type</strong></td>
                                        <td class="TdDesign" width="10%" align="center"><strong>Date</strong></td>
                                        <td class="TdDesign" width="10%" align="center"><strong>Date</strong></td>
                                        <td class="TdDesign" width="10%" align="center"><strong>To Date</strong></td>
                                        <td class="TdDesign" width="10%" align="center"><strong>Status</strong></td>
                                        </tr></tbody></table>
                            </div>
                    </div>

我想实现到MPDF中打印页面。

预期结果

这是我得到的解决方案

    <style>
    .divTable{
        display: table;
        width: 100%;
    }
    .divTableRow {
        display: table-row;
    }
    .divTableHeading {
        background-color: #EEE;
        display: table-header-group;
    }
    .divTableCell, .divTableHead {
        border: 1px solid #999999;
        display: table-cell;
        padding: 3px 10px;
    }
    .divTableHeading {
        background-color: #EEE;
        display: table-header-group;
        font-weight: bold;
    }
    .divTableFoot {
        background-color: #EEE;
        display: table-footer-group;
        font-weight: bold;
    }
    .divTableBody {
        display: table-row-group;
    }
    </style>
    <div class="divTable">
        <div class="divTableCell">Leave</div>
            <div class="divTableCell">
                <div class="divTable">
                    <div class="divTableCell"><strong>No</strong></div>
                    <div class="divTableCell"><strong>Type</strong></div>
                    <div class="divTableCell"><strong>Date</strong></div>
                    <div class="divTableCell"><strong>From Date</strong></div>
                    <div class="divTableCell"><strong>To Date</strong></div>
                    <div class="divTableCell"><strong>Status</strong></div>
                </div>
            </div>
        </div>
    </div>