0

我有一个大<div>s 的列表,每个都可变高度,但宽度固定。该列表看起来有点像这样:

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,这似乎是最好的方法。

4

1 回答 1

1

类似的帖子:page-break-inside 的替代方案:由于兼容性问题而避免

我之前尝试为此找到一个优雅的 CSS 解决方案,但无济于事。如果上面的链接不起作用,请编写一个脚本来计算每个段落的高度(包括间距)并相应地适合代表一页长的固定高度 div。

于 2012-08-23T18:09:04.273 回答