我知道也有类似的问题,但是没有一个可以解决我的问题。我要使用mPDF进行以下操作:
Page 1: Text for item 1
Page 2: Full width and height image to cover the page with an image of item 1
Page 3: Text for item 2
Page 4: Full width and height image to cover the page with an image of item 2
...
Run Code Online (Sandbox Code Playgroud)
以下代码以一种我想要实现的方式拉伸图像:
body {
background-image:url("image1.jpg");
background-image-resize: 5;
background-position: top center;
}
Run Code Online (Sandbox Code Playgroud)
但这导致将图像设置在每个页面上(我知道,它是body元素)。所以我尝试了以下方法:
<div style='
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image:url("image1.jpg");
background-image-resize: 5;
background-position: top center;
'></div>
Run Code Online (Sandbox Code Playgroud)
但这是行不通的。所以我尝试了相同的代码,只是用了颜色,而不是图像:
<div …Run Code Online (Sandbox Code Playgroud) mpdf ×1