newbie to html css.
I want to make a fixed border outside the main content of the webpage.If i scroll… the border shouldnt move.
Tried to give padding to the body,outside a wrapper but it doesnt stick to the content when i scroll kinda confuse what to try
2
Answers
I believe this is the CSS you looking for to style a border for the webpage, which sticks when scrolling. You can experiment with different values of top/right/bottom/left to match your preference.
It depends on exactly what you want to happen inside the frame – especially where do you want scroll bars to be?
This snippet does the following:
Removes the default margin that browsers tend to put on the body element.
Puts the frame on through a pseudo before element (i.e. not in the DOM, as it’s only for visual effect) which sits above the body (z-index) but doesn’t itself respond to pointer events.
This pseudo element is positioned fixed – which means it is positioned in relation to the viewport – and sized according to the viewport.
Puts all remaining content inside a unique element #content