【发布时间】:2017-04-16 14:46:15
【问题描述】:
我正在尝试使用 dompdf 将产品图库图像转换为 PDF,但它与图像重叠而不是在下一行显示它们(对于解决方案,我也尝试了 <br> 但对我不起作用)
if(isset($data) && count($data)>0){
$html="<link rel='stylesheet' href='".get_template_directory_uri()."/assets/css/woocommerce.css'>";
$html.="<link rel='stylesheet' href='".get_template_directory_uri()."/style.css'>";
$html.="<div style='text-align: center;'><h1>".$project_title."</h1><span><h3>".$project_sub_title."</h3></span></div>";
$html.='<div id="pdf_main"><ul class="products clearfix products-3 pdf_class">';
$counter=1;
while ($data = mysql_fetch_assoc($result)) {
$html.='<li class=" product type-product status-publish has-post-thumbnail product_cat-bedroom instock shipping-taxable purchasable product-type-simple">
<img src="'.$data['img'].'" class="attachment-shop_catalog size-shop_catalog">
</a>
<div class="product-details">
<div class="product-details-container">
<h3 class="" data-fontsize="16" data-lineheight="24">'.$data['product_title'].'</h3>
</div>
</div>
</li>';
}
$html.="</ul></div>";
$options = new Options();
$options->set('isRemoteEnabled', true);
$dompdf = new Dompdf($options);
$dompdf->loadHtml($html);
$dompdf->setPaper('A4', 'portrait');
$dompdf->render();
$dompdf->stream('Products.pdf');
$output = $dompdf->output();
}
这里是css
.products li.product { background-color: transparent; }
.products-3 > li:nth-child(3n+1) { clear: both; content: " "; display: block;}
.products li { border-color: #ebeaea;}
.products-3 > li { float: left; margin-bottom: 11px; margin-right: 1%; width: 32.6%;}
.products > li { -moz-border-bottom-colors: none; -moz-border-left-colors: none; -moz-border-right-colors: none; -moz-border-top-colors: none; border-color: #efefef; border-image: none; border-style: solid; border-width: 1px 1px 2px;}
.product { position: relative;}
看到第四张图片被切了一半,第五张也没有显示,在我的 css 中,我在第三个产品之后清除浮动,但它不工作并且重叠图像
【问题讨论】:
-
你能发布你的 CSS 吗?
-
@ChrisHappy 我添加了 css