我有一个大<div>
个列表,每个都有可变高度但固定宽度。该列表看起来有点像这样:
1. Heading
This is a short paragraph. It doesn't contain very many sentences.
2. Heading
Now this paragraph, THIS one, is quite long. It could be over 10 lines in
length. It might be even longer. Now this paragraph is aimless and going
nowhere and I'm annoying the good folks on Stack Overflow because they might
actually be helping me, and reading this is boring.
----------------------------------- Page Break ----------------------------------
3. Heading
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse sapien
orci, fermentum ac pellentesque quis, pretium at odio. Fusce quis dignissim
nisi. Ut rhoncus tortor ut diam aliquam auctor ullamcorper vitae urna.
Pellentesque elementum urna sed quam vehicula et elementum orci accumsan.
Nullam feugiat tempor ipsum et rhoncus. Maecenas ultrices, sem a posuere
pharetra, mi lorem rhoncus dolor, ac consectetur mauris tortor quis nulla.
Mauris consequat tincidunt nibh, consectetur adipiscing erat vulputate ac.
----------------------------------- Page Break ----------------------------------
4. Heading
Sed magna mi, egestas non imperdiet id, interdum nec quam. Nullam et libero
a urna convallis congue ac ut tellus. Aliquam in erat metus. Sed tempus,
ipsum ut vehicula convallis, massa neque faucibus est, quis cursus dolor
feliset dolor. Vivamus ultrices odio purus, vitae condimentum mi. Aenean
lacus dui, pellentesque vestibulum pretium sed, cursus non metus. Praesent
quis velit a lacus commodo adipiscing. Donec sollicitudin arcu quis est
faucibus malesuada. Curabitur sem quam, accumsan sed tempor sed, tincidunt
imperdiet nisl. Fusce non malesuada elit. Donec dolor eros, lacinia ut tempus
dictum, mi elementum elementum feugiat, metus augue dapibus felis, eget
pharetra lectus elit quis sapien. Nulla ullamcorper, elit in sodales
tincidunt, purus nisi venenatis sem, sit amet blandit nisl lorem non velit.
Nullam vulputate, dui auctor consectetur pellentesque, est nibh vulputate
eros, non egestas ante nunc a dui. Donec porta mollis pharetra. Quisque ut
nisl turpis. Maecenas et sem a magna lacinia porta nec non nulla.
Vestibulum sed justo sit amet lorem consectetur auctor eu nec neque.
Curabitur dignissim pellentesque sollicitudin. Sed mattis arcu justo.
Nunc in felis elit.
我想将这个列表分成几个“页面”和“分页符”,分页,(每个在同一个HTML页面上),每个都有一个固定的高度。除非每页只有一个项目,否则我不希望将长段分开。我该怎么做呢?我认为jQuery可能是必不可少的,这很好,因为我怀疑它仅在CSS中是可能的。
我这样做是因为我想把它变成PDF,这似乎是最好的方法。
答案 0 :(得分:1)
类似的帖子:alternative to page-break-inside:avoid because of compatibility issues
我之前试图找到一个优雅的CSS解决方案,但无济于事。如果以上链接不起作用,请编写脚本来计算每个段落的高度(包括间距),并相应地拟合到表示页面长度的固定高度div。