gpt4 book ai didi

html - 使用固定大小的正文打印时如何删除 HTML 右边距?

转载 作者:行者123 更新时间:2023-11-28 01:42:21 24 4
gpt4 key购买 nike

使用以下代码,将 HTML 页面(正文)设置为 A4 大小:

<html>
<head>
<style type="text/css">
@page {
margin: 0;
}

body, html {
margin:0;
padding:0;
}

body {
height: 842px;
width: 595px;
}

section {
clear: both;
}
</style>
</head>
<body>
<section >
<div style="float:left;height:60px">x</div>
<div style="float:right;height:60px">y</div>
</section>
<section>
test
</section>
</body>
</html>

它将删除除右边以外的所有边距。

使用应用于正文的 A4 页面设置打印页面尺寸时如何删除右边距?

最佳答案

您可以为打印机创建一个 css 表:

<link rel="stylesheet" type="text/css" href="printing.css" media="print">

并将所有用于打印的修改都放在那里。

编辑:

或者像这样使用媒体查询:

@media print { 
body {
margin:0;
}
}

关于html - 使用固定大小的正文打印时如何删除 HTML 右边距?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50372598/

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