简体   繁体   English

HTML:将 h1 和 h2 保持在一起

[英]HTML: Keeping h1 and h2 together

I am using Oxygen XML Editor's built in DITA XML to HTML with CSS transformation to create a paged-media output. I am using Oxygen XML Editor's built in DITA XML to HTML with CSS transformation to create a paged-media output. In each chapter, I want to start each section on a new page.在每一章中,我都想在新的一页上开始每一节。 To do that I added a css entry of:为此,我添加了一个 ZC7A62​​8CBA22E28EB17B5F5C6AE2A266AZ 条目:

h2 {
page-break-before: always;
}

But, when I do that, of course it puts a page break between h1 and h2.但是,当我这样做时,它当然会在 h1 和 h2 之间放置一个分页符。 I want h1 and h2 to stay together on the first page of each new chapter, but I want each subsequent h2 to start on a new page.我希望 h1 和 h2 在每个新章节的第一页上保持一致,但我希望每个后续 h2 都从新页面开始。

Does anyone have any ideas how I can accomplish this in the css?有谁知道我如何在 ZC7A62​​8CBA22E28EB17B5F5C6AE2A266AZ 中实现这一点?

Thank you PJP谢谢PJP

Untested, but you could try breaking or not breaking per-article:未经测试,但您可以尝试打破或不打破每篇文章:

article {
  page-break-before: always;
}

article:first-of-type {
  page-break-before: auto;
}

Breaking on the h2 would be a variation on that:打破h2将是一个变化:

article h2 {
  page-break-before: always;
}

article:first-of-type h2 {
  page-break-before: auto;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM