Currently, Prince does not give us 'border-inside', only margin-inside (e.g. see http://www.princexml.com/forum/topic/717/padding-inside-padding-outside). But sometimes we really want a border-inside or border-outside, for example when we have sidenotes in an outer sidebar.
Hence this workaround! We position this element relative and give it a background color, then we put a pseudo element with a solid background colour exactly behind it (position: absolute
) adjusting top and bottom for padding if necessary.
We need to put some invisible content in there to make it appear.
Finally, we shift it inside slightly exposing its edge as a 'border', and hide the rest behind its parent with a negative z-index.