gpt4 book ai didi

asp.net - CSS 嵌套 Div 打印问题 : Text bunches at top of second page

转载 作者:行者123 更新时间:2023-11-28 14:57:40 25 4
gpt4 key购买 nike

这是我目前使用的 HTML 和内联 CSS:

<div style="width: 975px; clear: both; float: left; text-align: left; margin: 0;
background-color: #D3D3D3;">
<div style="width: 384px; float: left; height: 20px; margin: 0;">
<span style="font-style: italic; font-size: 13px; padding-left: 80px;">Test Group 1</span></div>
<div style="background-color: #BEE0F7; width: 165px; height: 20px; float: right;
padding: 0; margin: 0; font-weight: bold; border-bottom: 3px double;">
<div style="font-size: 13px; padding-left: 8px; text-align: right; width: 70px; display: block;
position: absolute;">
$0.00</div>
<div style="font-size: 13px; padding-left: 90px; text-align: right; width: 70px;
display: block; position: absolute;">
$0.00</div>
</div>
<div style="background-color: #CFF5CE; width: 166px; height: 20px; float: right;
margin: 0; font-style: italic; font-weight: bold; border-bottom: 3px double;">
<div style="font-size: 13px; padding-left: 80px; text-align: right; width: 70px;
display: block; position: absolute;">
$0.00</div>
<div style="font-size: 13px; text-align: right; width: 70px; display: block;
position: absolute;">
$0.00</div>
</div>
<div style="background-color: #F0D3D3; width: 253px; height: 20px; float: right;
margin: 0; font-weight: bold; font-style: italic; border-bottom: 3px double;">
<div style="font-size: 13px; padding-left: 175px; text-align: right; width: 70px;
display: block; position: absolute;">
$0.00</div>
<div style="font-size: 13px; padding-left: 90px; text-align: right; width: 70px;
display: block; position: absolute;">
$0.00</div>
<div style="font-size: 13px; padding-left: 10px; text-align: right; width: 70px;
display: block; position: absolute;">
$0.00</div>
</div>
</div><div style="width: 975px; clear: both; float: left; text-align: left; display: block;
margin: 0; background-color: #D3D3D3;">
<div style="width: 384px; float: left; height: 20px; margin: 0; display: block;">
</div>
<div style="background-color: #BEE0F7; width: 165px; height: 20px; float: right;
padding: 0; margin: 0; display: block;">
</div>
<div style="background-color: #CFF5CE; width: 166px; height: 20px; float: right;
margin: 0; display: block;">
</div>
<div style="background-color: #F0D3D3; width: 253px; height: 20px; float: right;
margin: 0; display: block;">
</div>
</div>
<div style="width: 975px; clear: both; float: left; text-align: left; margin: 0;
display: block; background-color: #D3D3D3;">
<div style="width: 384px; float: left; height: 20px; margin: 0; display: block;">
<span style="font-size: 13px; padding-left: 130px;">L GROUP</span></div>
<div style="background-color: #BEE0F7; width: 165px; height: 20px; float: right;
padding: 0; margin: 0; display: block; border-bottom: 3px double;">
<div style="font-size: 13px; padding-left: 8px; text-align: right; width: 70px; display: block;
position: absolute;">
$0.00</div>
<div style="font-size: 13px; padding-left: 90px; text-align: right; width: 70px;
display: block; position: absolute;">
$0.00</div>
</div>
<div style="background-color: #CFF5CE; width: 166px; height: 20px; float: right;
margin: 0; display: block; border-bottom: 3px double;">
<div style="font-size: 13px; padding-left: 80px; text-align: right; width: 70px;
display: block; position: absolute;">
$0.00</div>
<div style="font-size: 13px; text-align: right; width: 70px; display: block;
position: absolute;">
$0.00</div>
</div>
<div style="background-color: #F0D3D3; width: 253px; height: 20px; float: right;
margin: 0; display: block; border-bottom: 3px double;">
<div style="font-size: 13px; padding-left: 175px; text-align: right; width: 70px;
display: block; position: absolute;">
$0.00</div>
<div style="font-size: 13px; padding-left: 90px; text-align: right; width: 70px;
display: block; position: absolute;">
$0.00</div>
<div style="font-size: 13px; padding-left: 10px; text-align: right; width: 70px;
display: block; position: absolute;">
$0.00</div>
</div>
</div>
<div style="width: 975px; clear: both; float: left; text-align: left; margin: 0;
display: block; background-color: #D3D3D3;">
<div style="width: 390px; float: left; height: 20px; margin: 0; display: block;">
<div style="font-size: 13px; padding-left: 324px; text-align: right; width: 60px;
display: block; position: absolute;">
<span id="lnkInvoice17">828</span></div>
<div style="font-size: 13px; padding-left: 264px; text-align: right; width: 35px;
display: block; position: absolute;">
5.00000%</div>
<div style="font-size: 13px; text-align: left; padding-left: 197px; width: 60px;
display: block; position: absolute;">
7/14/2010</div>
</div>
<div style="background-color: #BEE0F7; width: 165px; height: 20px; float: right;
padding: 0; margin: 0; display: block; border-bottom: 1px solid;">
<div style="font-size: 13px; padding-left: 8px; text-align: right; width: 70px; display: block;
position: absolute;">
$0.00</div>
<div style="font-size: 13px; padding-left: 90px; text-align: right; width: 70px;
display: block; position: absolute;">
$0.00</div>
</div>
<div style="background-color: #CFF5CE; width: 166px; height: 20px; float: right;
margin: 0; display: block; border-bottom: 1px solid;">
<div style="font-size: 13px; padding-left: 80px; text-align: right; width: 70px;
display: block; position: absolute;">
$0.00</div>
<div style="font-size: 13px; text-align: right; width: 70px; display: block;
position: absolute;">
$0.00</div>
</div>
<div style="background-color: #F0D3D3; width: 253px; height: 20px; float: right;
margin: 0; display: block; border-bottom: 1px solid;">
<div style="font-size: 13px; padding-left: 175px; text-align: right; width: 70px;
display: block; position: absolute;">
$0.00</div>
<div style="font-size: 13px; padding-left: 90px; text-align: right; width: 70px;
display: block; position: absolute;">
$0.00</div>
<div style="font-size: 13px; padding-left: 10px; text-align: right; width: 70px;
display: block; position: absolute;">
$0.00**</div>
</div>
</div>
<div style="width: 975px; clear: both; float: left; text-align: left; margin: 0;
display: block; background-color: #D3D3D3;">
<div style="width: 390px; float: left; height: 20px; margin: 0; display: block;">
<div style="font-size: 13px; padding-left: 324px; text-align: right; width: 60px;
display: block; position: absolute;">
<span id="lnkInvoice18">828</span></div>
</div>
<div style="background-color: #BEE0F7; width: 165px; height: 20px; float: right;
padding: 0; margin: 0; display: block;">
</div>
<div style="background-color: #CFF5CE; width: 166px; height: 20px; float: right;
margin: 0; display: block;">
</div>
<div style="background-color: #F0D3D3; width: 253px; height: 20px; float: right;
margin: 0; display: block;">
<div style="font-size: 13px; padding-left: 175px; text-align: right; width: 70px;
display: block; position: absolute;">
$0.00</div>
<div style="font-size: 13px; padding-left: 90px; text-align: right; width: 70px;
display: block; position: absolute;">
$0.00</div>
<div style="font-size: 13px; padding-left: 10px; text-align: right; width: 70px;
display: block; position: absolute;">
$165,165.12</div>
</div>
</div>
<div style="width: 975px; clear: both; float: left; text-align: left; display: block;
margin: 0; background-color: #D3D3D3;">
<div style="width: 384px; float: left; height: 20px; margin: 0; display: block;">
</div>
<div style="background-color: #BEE0F7; width: 165px; height: 20px; float: right;
padding: 0; margin: 0; display: block;">
</div>
<div style="background-color: #CFF5CE; width: 166px; height: 20px; float: right;
margin: 0; display: block;">
</div>
<div style="background-color: #F0D3D3; width: 253px; height: 20px; float: right;
margin: 0; display: block;">
</div>
</div>

这段代码基本上是一堆嵌套的 DIVS,用作可展开/可折叠的 div 结构。为了打印出来,我删除了所有功能。然而,问题是该页面在打印预览中显示完美......直到它需要分页到下一页。第二页的其余文本都在页面顶部乱七八糟:

alt text

有人知道发生了什么事吗?我假设这是一个 FLOAT 或 INLINE/BLOCK 问题,但我似乎无法弄清楚是哪个。

最佳答案

尝试使用这个 HTML

<div class="clearfix" style="width: 975px; float: left; text-align: left; margin: 0;
background-color: #D3D3D3;">
<div style="width: 384px; float: left; height: 20px; margin: 0;">
<span style="font-style: italic; font-size: 13px; padding-left: 80px;">Test Group 1</span>
</div>
<div style="background-color: #BEE0F7; width: 165px; height: 20px; float: right;
padding: 0; margin: 0; font-weight: bold; border-bottom: 3px double;">
<div style="font-size: 13px; padding-left: 8px; text-align: right; width: 70px; display: block;
position: absolute;">
$0.00
</div>
<div style="font-size: 13px; padding-left: 90px; text-align: right; width: 70px;
display: block; position: absolute;">
$0.00
</div>
</div>
<div style="background-color: #CFF5CE; width: 166px; height: 20px; float: right;
margin: 0; font-style: italic; font-weight: bold; border-bottom: 3px double;">
<div style="font-size: 13px; padding-left: 80px; text-align: right; width: 70px;
display: block; position: absolute;">
$0.00
</div>
<div style="font-size: 13px; text-align: right; width: 70px; display: block; position: absolute;">
$0.00
</div>
</div>
<div style="background-color: #F0D3D3; width: 253px; height: 20px; float: right;
margin: 0; font-weight: bold; font-style: italic; border-bottom: 3px double;">
<div style="font-size: 13px; padding-left: 175px; text-align: right; width: 70px;
display: block; position: absolute;">
$0.00
</div>
<div style="font-size: 13px; padding-left: 90px; text-align: right; width: 70px;
display: block; position: absolute;">
$0.00
</div>
<div style="font-size: 13px; padding-left: 10px; text-align: right; width: 70px;
display: block; position: absolute;">
$0.00
</div>
</div>
</div>
<div class="clearfix" style="width: 975px; float: left; text-align: left; display: block;
margin: 0; background-color: #D3D3D3;">
<div style="width: 384px; float: left; height: 20px; margin: 0; display: block;">
</div>
<div style="background-color: #BEE0F7; width: 165px; height: 20px; float: right;
padding: 0; margin: 0; display: block;">
</div>
<div style="background-color: #CFF5CE; width: 166px; height: 20px; float: right;
margin: 0; display: block;">
</div>
<div style="background-color: #F0D3D3; width: 253px; height: 20px; float: right;
margin: 0; display: block;">
</div>
</div>
<div class="clearfix" style="width: 975px; float: left; text-align: left; margin: 0;
display: block; background-color: #D3D3D3;">
<div style="width: 384px; float: left; height: 20px; margin: 0; display: block;">
<span style="font-size: 13px; padding-left: 130px;">L GROUP</span></div>
<div style="background-color: #BEE0F7; width: 165px; height: 20px; float: right;
padding: 0; margin: 0; display: block; border-bottom: 3px double;">
<div style="font-size: 13px; padding-left: 8px; text-align: right; width: 70px; display: block;
position: absolute;">
$0.00
</div>
<div style="font-size: 13px; padding-left: 90px; text-align: right; width: 70px;
display: block; position: absolute;">
$0.00
</div>
</div>
<div style="background-color: #CFF5CE; width: 166px; height: 20px; float: right;
margin: 0; display: block; border-bottom: 3px double;">
<div style="font-size: 13px; padding-left: 80px; text-align: right; width: 70px;
display: block; position: absolute;">
$0.00
</div>
<div style="font-size: 13px; text-align: right; width: 70px; display: block; position: absolute;">
$0.00
</div>
</div>
<div style="background-color: #F0D3D3; width: 253px; height: 20px; float: right;
margin: 0; display: block; border-bottom: 3px double;">
<div style="font-size: 13px; padding-left: 175px; text-align: right; width: 70px;
display: block; position: absolute;">
$0.00
</div>
<div style="font-size: 13px; padding-left: 90px; text-align: right; width: 70px;
display: block; position: absolute;">
$0.00
</div>
<div style="font-size: 13px; padding-left: 10px; text-align: right; width: 70px;
display: block; position: absolute;">
$0.00
</div>
</div>
</div>
<div class="clearfix" style="width: 975px; float: left; text-align: left; margin: 0;
display: block; background-color: #D3D3D3;">
<div style="width: 390px; float: left; height: 20px; margin: 0; display: block;">
<div style="font-size: 13px; padding-left: 324px; text-align: right; width: 60px;
display: block; position: absolute;">
<span id="lnkInvoice17">828</span>
</div>
<div style="font-size: 13px; padding-left: 264px; text-align: right; width: 35px;
display: block; position: absolute;">
5.00000%
</div>
<div style="font-size: 13px; text-align: left; padding-left: 197px; width: 60px;
display: block; position: absolute;">
7/14/2010
</div>
</div>
<div style="background-color: #BEE0F7; width: 165px; height: 20px; float: right;
padding: 0; margin: 0; display: block; border-bottom: 1px solid;">
<div style="font-size: 13px; padding-left: 8px; text-align: right; width: 70px; display: block;
position: absolute;">
$0.00
</div>
<div style="font-size: 13px; padding-left: 90px; text-align: right; width: 70px;
display: block; position: absolute;">
$0.00
</div>
</div>
<div style="background-color: #CFF5CE; width: 166px; height: 20px; float: right;
margin: 0; display: block; border-bottom: 1px solid;">
<div style="font-size: 13px; padding-left: 80px; text-align: right; width: 70px;
display: block; position: absolute;">
$0.00
</div>
<div style="font-size: 13px; text-align: right; width: 70px; display: block; position: absolute;">
$0.00
</div>
</div>
<div style="background-color: #F0D3D3; width: 253px; height: 20px; float: right;
margin: 0; display: block; border-bottom: 1px solid;">
<div style="font-size: 13px; padding-left: 175px; text-align: right; width: 70px;
display: block; position: absolute;">
$0.00
</div>
<div style="font-size: 13px; padding-left: 90px; text-align: right; width: 70px;
display: block; position: absolute;">
$0.00
</div>
<div style="font-size: 13px; padding-left: 10px; text-align: right; width: 70px;
display: block; position: absolute;">
$0.00**
</div>
</div>
</div>
<div class="clearfix" style="width: 975px; float: left; text-align: left; margin: 0;
display: block; background-color: #D3D3D3;">
<div style="width: 390px; float: left; height: 20px; margin: 0; display: block;">
<div style="font-size: 13px; padding-left: 324px; text-align: right; width: 60px;
display: block; position: absolute;">
<span id="lnkInvoice18">828</span>
</div>
</div>
<div style="background-color: #BEE0F7; width: 165px; height: 20px; float: right;
padding: 0; margin: 0; display: block;">
</div>
<div style="background-color: #CFF5CE; width: 166px; height: 20px; float: right;
margin: 0; display: block;">
</div>
<div style="background-color: #F0D3D3; width: 253px; height: 20px; float: right;
margin: 0; display: block;">
<div style="font-size: 13px; padding-left: 175px; text-align: right; width: 70px;
display: block; position: absolute;">
$0.00
</div>
<div style="font-size: 13px; padding-left: 90px; text-align: right; width: 70px;
display: block; position: absolute;">
$0.00
</div>
<div style="font-size: 13px; padding-left: 10px; text-align: right; width: 70px;
display: block; position: absolute;">
$165,165.12
</div>
</div>
</div>
<div class="clearfix" style="width: 975px; float: left; text-align: left; display: block;
margin: 0; background-color: #D3D3D3;">
<div style="width: 384px; float: left; height: 20px; margin: 0; display: block;">
</div>
<div style="background-color: #BEE0F7; width: 165px; height: 20px; float: right;
padding: 0; margin: 0; display: block;">
</div>
<div style="background-color: #CFF5CE; width: 166px; height: 20px; float: right;
margin: 0; display: block;">
</div>
<div style="background-color: #F0D3D3; width: 253px; height: 20px; float: right;
margin: 0; display: block;">
</div>
</div>

添加这个 CSS

<script type="text/css">
.clearfix:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}

.clearfix {
display: inline-block;
}

html[xmlns] .clearfix {
display: block;
}

* html .clearfix {
height: 1%;
}

</script>

关于asp.net - CSS 嵌套 Div 打印问题 : Text bunches at top of second page,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3241578/

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