【发布时间】:2014-07-24 00:25:58
【问题描述】:
我正在使用 dompdf 库生成 PDF,但由于 dompdf 库不支持它,因此无法使用大表。所以我将表格更改为使用span 标签并使用display: table-cell 和display: table-row 设置元素样式。
问题是dompdf 仍然将这些跨度标签视为表格(因为样式)。
问题:
在不使用display: table-cell 和display: table-row 且不使用表格的情况下,我是否可以使用其他css 样式来获得相同的外观和感觉?
这是我的代码:
HTML:
<span class="table">
<span class="tr">
<span class="th h2">Request Information</span>
</span>
<span class="tr">
<span class="td">Quote #</span>
<span class="td">sdfsdfsdfsf</span>
</span>
<span class="tr">
<span class="td">Project Number</span>
<span class="td">sdfsdfsdfsd</span>
</span>
<span class="tr">
<span class="td">Account Manager</span>
<span class="td">khksjksjhdf</span>
</span>
<span class="tr">
<span class="td">Customer</span>
<span class="td">ljsljflksjd</span>
</span>
<span class="tr">
<span class="td">Customer Location</span>
<span class="td">
123 Fake Street<br>
City, State ZIPCode
</span>
</span>
<span class="tr">
<span class="td">Customer Contact</span>
<span class="td">lsjdlfkjslkjdfs</span>
</span>
<span class="tr">
<span class="td">Date Submitted</span>
<span class="td">sdfsdfgdfg</span>
</span>
<span class="tr">
<span class="td">Date Approved</span>
<span class="td">N/A</span>
</span>
</span>
CSS:
span {
width: 72% !important;
padding: 5px 0px 5px 0px;
/*padding-bottom: 9px;*/
/*border: 1px solid Black;*/
}
span.table {
/*border-collapse: collapse;*/
/*display: table;*/
}
span .td {
border: none !important;
background: White !important;
display: table-cell;
padding-left: 10px;
font-size: 16px;
margin-bottom: 30px;
border:none !important;
}
span .tr {
display: table-row;
border: 1px solid Black;
padding: 2px 2px 2px 5px;
background-color: #f5f5f5;
}
span .th {
text-align: left;
font-weight: bold;
}
jsFiddle:http://jsfiddle.net/Mn7GH/
【问题讨论】:
-
display: table /*
/ display: table-cell /
/ display: table-row / / display: table-column / / display: table-column-group / / display: table-footer-group / i> / display: table-header-group / */ 是的,我试图完全避免使用表格。如果我使用display: table或表格标签,这并不重要。我不能使用其中任何一个。我需要在不使用任何形式的表格的情况下获得相同的外观和感觉。您需要使用 display 属性。然后您可以将行为更改为类似于表格行和单元格,例如是的,我知道这一点。问题是当我这样做时,dompdf将样式视为表格标签。所以我不能使用display样式。我需要其他方法让它们看起来一样。