gpt4 book ai didi

css - 如何以最大尺寸在每张(纸)纸上打印 1 张图像

转载 作者:行者123 更新时间:2023-11-28 11:09:48 29 4
gpt4 key购买 nike

对于仅包含图像的 HTML 文档,如何缩放图像以填满整个工作表?我希望图像缩放它的宽度/高度以尽可能大/尽可能小以适合一张纸。

我开始用它来分页

footer {page-break-after:always;}

我不知道从哪里开始设置图像的高度/宽度?

想法?

最佳答案

html

<img class="printThisFull" src="http://placehold.it/350x150" alt="Klematis" width="110" height="90">
<img class="printThisFull" src="http://placehold.it/350x150" alt="Klematis" width="110" height="90">

如果你想将图片拉伸(stretch)到整个页面区域

 @media print {
.printThisFull {
width:100%;
height:100%;
page-break-after:always
}
}

如果你想在保持宽高比的情况下将图像调整为整页宽度

 @media print {
.printThisFull {
width:100%;
height:auto;
page-break-after:always
}
}

如果你想在保持宽高比的情况下将图像调整为整页高度

 @media print {
.printThisFull {
width:auto;
height:100%;
page-break-after:always
}
}

你可以试试这个

用下面的代码制作新的 html 文件并在浏览器中启动它,按 crt + p,你会看到它工作。

<!doctype html>
<body>
<img class="printThisFull" src="http://placehold.it/350x150" alt="Klematis" width="110" height="90">
<img class="printThisFull" src="http://placehold.it/350x150" alt="Klematis" width="110" height="90">
<style>
@media print {
.printThisFull {
width:100%;
height:auto;
page-break-after:always
}
}
</style>
</body>

</html>

关于css - 如何以最大尺寸在每张(纸)纸上打印 1 张图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24364707/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com