Answer the question
In order to leave comments, you need to log in
Document fragmentation with fixed top navigation. How?
Essence of the question: there is a page with text and a menu with links to paragraphs of this text. Example here: jsfiddle.net/zLeau0qz
The problem is that there is a fixed navigation menu at the top of the page. When you click on the links to the paragraphs of the text, the headings of these paragraphs are closed by the navigation menu. Is there a simple css + html solution?
UPD: Maybe somehow you can screw something like this, but more beautifully?
h2:target {
padding-top: 40px;
}
Answer the question
In order to leave comments, you need to log in
I doubt very much that it will turn out more beautiful ... at least margin , at least padding .
But I will offer you something else:
document.querySelector("aside").onclick = function(e){
var tr = e.target.href;
if(tr){
e.preventDefault();
window.scrollTo(
0,
window.pageYOffset + document.querySelector("#"+tr.split("#")[1]).getBoundingClientRect().top - 60
);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question