当打印(输出PDF)以下html时,图像周围有时会出现不需要的边框/空白。有时它出现在左侧的其他时间的右侧。它似乎只有一个像素宽。
我已经尝试display: block;
无济于事。
如何摆脱图像周围的空白?
体:
<body>
<div class="doc">
<div class="container-row">
<div class="container leftSide">
<div class="item">Item A</div>
<img class="image" src="http://via.placeholder.com/350x450">
</div>
</div>
<div class="container-row">
<div class="container rightSide">
<div class="item">Item A</div>
<img class="image" src="http://via.placeholder.com/350x450">
</div>
</div>
<!-- plus more "container-row"s -->
</div>
</body>
css的相关部分:
@media print {
.container-row {
page-break-inside: avoid;
}
}
body {
background-color: transparent;
margin: 0 !important;
padding: 0 !important;
}
.doc {
font-size: 0;
}
.container-row {
display: inline-block;
width: 100%;
border: 1px transparent solid;
font-size: 10px;
}
.container {
max-width: 75%;
word-wrap: break-word;
margin: 10px 10px 0px 10px;
overflow: hidden;
}
.image {
width: 100%;
margin: 5px 0px -5px;
}
.leftSide {
float: left;
border-top-left-radius: 13px;
border-top-right-radius: 13px;
border-bottom-right-radius: 13px;
}
.rightSide {
float: right;
border-top-left-radius: 13px;
border-top-right-radius: 13px;
border-bottom-left-radius: 13px;
}
.item {
margin: 7px 10px 1px 10px;
}
.container p {
margin-top: 0px;
margin-left: 10px;
margin-bottom: 7px;
margin-right: 10px;
padding: 0px;
}
答案 0 :(得分:0)
通过将image
类的css调整为:
.image {
width: 102%;
margin: 5px -1% -5px;
}