php - DOMPDF,表格单元格垂直对齐问题

标签 php html css dompdf codeigniter-3

此代码在浏览器上运行完美,但问题是当我使用 dompdf 填充动态数据并生成 PDF 时然后<td>item</td>整列位于单元格顶部。

解决方案是什么?

浏览器这样显示Browsers View但 dom pdf 生成的 PDF 显示如下 Generated PDF View

body {
            font-family: "Open Sans","Helvetica Neue",Helvetica,Arial,sans-serif;
        }
        #header { position: fixed; left: 0px; width:100%; bottom: -150px; right: 0px; height: 150px; background-color: #4b94d9; color:#000; text-align: left; }
	#page-wrap {
            width: 700px;
            margin: 0 auto;
	}
        .center-justified {
            text-align: justify;
            margin: 0 auto;
            width: 30em;
	}
	table.outline-table {
            border: 1px solid;
            border-spacing: 0;
	}
	tr.border-bottom td, td.border-bottom {
            border-bottom: 1px solid;
	}
	tr.border-top td, td.border-top {
            border-top: 1px solid;
	}
	tr.border-right td, td.border-right {
            border-right: 1px solid;
	}
	tr.border-right td:last-child {
            border-right: 0px;
	}
	tr.center td.center {
            text-align: center;
            valign:"middle";
	}
    
	td.pad-left {
            padding-left: 5px;
            line-height: 2;
	}
	tr.right-center td, td.right-center {
            text-align: right;
            padding-right: 50px;
	}
	tr.right td, td.right {
            text-align: right;
	}
        .content > div > span{
            display:inline-block;
            width:50%; /* or choose some other value */
        }
        .contentdate > div > span{
            display:inline-block;
            width:35%; /* or choose some other value */
        }
<table width="100%" class="outline-table">
<tbody> 
<tr class="border-bottom border-right" style="background:#353940;color:#FFF;">
   <td width="35%" class="pad-left"><strong>Item</strong></td>
   <td width="10%" style="text-align:center;"><strong>Quantity</strong></td>
   <td width="10%" class="right"><strong>Unit Cost</strong></td>
   <td width="15%" class="right"><strong>Total</strong></td>
</tr>
<tr class="border-right">
   <td class="pad-left">some item name one</td>
   <td style="text-align:center;">15</td>
   <td class="right">1500.00</td>
   <td class="right">22500.00</td>
</tr>
</tbody>
</table>

此代码在浏览器上运行完美,但问题是当我使用 dompdf 填充动态数据并生成 PDF 时然后<td>item</td>整列位于单元格顶部。

解决方案是什么?

最佳答案

Try This.

td.pad-left {
        padding-left: 5px;
        //line-height: 2; <--remove this
}

Html

    <tr class="border-right">
       <!-- give margin top in particular line -->
       <td class="pad-left"><p style="margin-top:10px;">some item name one</p></td>
       <td style="text-align:center;">15</td>
       <td class="right">1500.00</td>
       <td class="right">22500.00</td>
    </tr>

关于php - DOMPDF,表格单元格垂直对齐问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32740903/

相关文章:

php - 用于从句子中解析单词的正则表达式

php - 我如何防止在 PHP 中重复提交表单(跨多个窗口进行保护)?

javascript - 表中的 jQuery slideDown 和 SlideUp 看起来不正确

html - 垂直对齐 block <a> 标签中的一些文本

CSS 优先级

php - 使用 jquery 和 CSS 的验证不起作用

php - 同时疯狂混淆PHP OOP "implements" "extends"

php - 在 PHP 中查找全局变量的声明

php - 我怎样才能把这个 jQuery 点击函数变成 keyup 函数?

python - 读取 html 文件并将其显示在 tkinter 窗口中