select the last page of every chapter?
My designer wants to have a specific graphic for the background image of the last page of every chapter. That last page may be blank or may have content, depending. How can I select for that page without knowing what content is flowing onto it in each instance?
I tried adding a <div> with a unique class and setting that as a named page, but that inserts a page break and prints the background image on the new blank page.
You can't do this at the moment, there is no :last page selector.
You can put content at the end of the chapter, eg. with the ::after pseudo-element.
However, does it make sense to have a background image on the last page when you don't know how much content the last page will have on it? Does the background image cover the whole page area, or does it just appear in part of the page?
The background image only covers the bottom of the page, outside the content area.
I should mention, there is an existing background image that covers the footer area, from the default @page settings.
If you can put an image (or a container for the image) manually at the end of of each chapter maybe this is possible, please see the example attached for a first start. If it is impossible to do this manually it could easily be done with a litte JavaScript that inserts the image before the start of a new chapter.
- test.zip 23.8 kB
Yes you can do this, you can also used CSS pseudo-elements, eg. if you have <div class="chapter"> you can put something at the end of it with div.chapter::after { content: ... }
Are you planing to add a :last page-selector in the future?
It would be nice, but can be technically challenging due to the ability to create circular definitions. Maybe one day.