【发布时间】:2016-05-04 15:43:25
【问题描述】:
对我的 CSS 有不同的处理方式吗?
我有一些 html 代码和一些 CSS 样式,试图生成一个 PDF,其中我的示例文本容器/div 向右浮动。如果我自己加载 html 站点,则 CSS 都是正确的并且看起来很好。但是当我从代码转换为 PDF 文件时,它输出错误。任何人都可以提出一种可行的方法吗?
我的代码:
<html>
<head>
<style>
@page {
margin: 0px 0px 0px 0px;
}
body {
height: 100%;
margin: 0px 0px 0px 0px;
background-size: 100% 100%;
background-repeat: no-repeat;
}
#top,
#bottom {
position: fixed;
left: 0;
right: 0;
height: 50%;
}
#top {
top: 0;
background-color: orange;
}
#bottom {
bottom: 0;
background-color: green;
}
div.mainLayout{position: relative;float:right;width:50%;height:100%;}
.textstuff {
background-color:aqua;
left:0;
height: 100%;
width:100%;
}
</style>
</head>
<body>
<div id="top">
<div class="mainLayout">
<div class="textstuff">
<center>
<font size="5" style="padding-bottom:5px">Sample Text 1</font><br />
<font size="4" style="padding-bottom:5px">Sample Text 2</font><br />
<font size="5" style="padding-bottom:25px">Sample Text 3</font><br />
<font size="4">Sample Text 4</font>
</center>
</div>
</div>
</div>
<div id="bottom">
<div class="mainLayout">
<div class="textstuff">
<center>
<font size="5" style="padding-bottom:5px">Sample Text 1</font><br />
<font size="4" style="padding-bottom:5px">Sample Text 2</font><br />
<font size="5" style="padding-bottom:25px">Sample Text 3</font><br />
<font size="4">Sample Text 4</font>
</center>
</div>
</div>
</div>
</body>
</html>
【问题讨论】: