Forum How do I...?

Background in page number

cayhorstmann
I use a rule

@page:left {
@top-left {
content: counter(page);
vertical-align: bottom;
color: white;
background: gray;
...
}
...
}

to make page numbers with a gray background. I am asked to format for letter size paper but with margins

@page {
margin: 1.5in 1.25in 1.5in 1.25in;
}

What can I do so that the background color doesn't escape those margins (see screenshot for what I don't want).

  1. Screenshot_2024-09-26_10-46-05.png225.9 kB
David J Prokopetz
Based on your example, it looks like what you're experiencing is the expected behaviour: by default, all margin boxes fill the entire space between the page margin and the edge of the page. If you want that not to be the case, you need to put a margin on the margin box itself; e.g., @top-left { margin-top: xx; }
cayhorstmann
Thanks, that works. I had previously put it outside the @top-left, thinking then it would apply to all three adornments, and that didn't work.