I’m not sure, it’s not a problem I’ve had to deal with. But one thing I have started doing is putting the ID for the anchor to target in the containing <section> element, rather than the heading, as I did before html5. So it’s like:-
If you gave the section elements sufficient padding-top the heading may clear the menu. That’s if you don’t mind having a bit of a gap between sections. I’ve not tried this, it’s just a thought.
There is no easy css way other than offsetting the destination by the needed amount which could be awkward in existing pages. You could add the target before the detination and use absolute positoning with a negative top margin equal to the height of the header.