I'm working on a layout that is quite similar to the one in the official "Textbook" sample document.
Basically the layout will have two columns: One "main" column and a "sidenote" column that is supposed to always be on the outside of the page.
My current approach is the one from the "Textbook" sample: Floating the sidenote to the outside with a negative margin to the outside.
The issue is: That will only work if the element that contains the sidenote (the paragraph or heading in my case) does not have any padding whatsoever. Once there is any padding involved (like in an <ul>), the negative margin I applied will be incorrect and the sidenote will not be floated to the correct position.
I have tried the following solutions:
So basically I can say that I can't solve this layout problem with floats. The negative margins are just a very bad hack. It works for simple stuff like in the "Textbook" sample, but not for my use-case because of the paddings.
What would work is absolute positioning. Basically I would always position my sidenotes to be at a specific distance from the outside.
For this to work, I'd need one of these two features in Prince:
Unfortunately both of these features are not available, so I don't see a way to use absolute positioning either.
Is there maybe another way that I haven't thought of? Or is one of the features I proposed above planned for the future?
Thanks in advance!
Lukas
Basically the layout will have two columns: One "main" column and a "sidenote" column that is supposed to always be on the outside of the page.
My current approach is the one from the "Textbook" sample: Floating the sidenote to the outside with a negative margin to the outside.
The issue is: That will only work if the element that contains the sidenote (the paragraph or heading in my case) does not have any padding whatsoever. Once there is any padding involved (like in an <ul>), the negative margin I applied will be incorrect and the sidenote will not be floated to the correct position.
I have tried the following solutions:
- Correct the negative margin by the amount of the padding with a "li > .sidenote" selector: Won't work, because the sidenotes are always floated to the outside, so either to the left or to the right of the main column. Result: A corrected negative margin only works on right pages, on left pages the margin is even more wrong. Also the whole "correct the negative margin" thing is quite a hack.
- Symmetric padding for <ul>s so that the correction can be the same no matter if on the left or on the right: Even more a hack and won't scale with larger paddings because it actually creates padding on the wrong side that was not intended.
So basically I can say that I can't solve this layout problem with floats. The negative margins are just a very bad hack. It works for simple stuff like in the "Textbook" sample, but not for my use-case because of the paddings.
What would work is absolute positioning. Basically I would always position my sidenotes to be at a specific distance from the outside.
For this to work, I'd need one of these two features in Prince:
- New CSS properties called "outside" and "inside" that work just like "left" and "right" but respect the current page (either being a left or right page).
- The ability to style elements differently depending on the page they are on. Basically the ability to have CSS rules for elements inside the @page rules that currently only accept styles for the page directly.
Unfortunately both of these features are not available, so I don't see a way to use absolute positioning either.
Is there maybe another way that I haven't thought of? Or is one of the features I proposed above planned for the future?
Thanks in advance!
Lukas