Answer the question
In order to leave comments, you need to log in
Why aren't absolutely positioned blocks stretched to the full width of the document?
Good evening, colleagues!
I have two blocks on the site with absolute position, there are lists of articles and a button at the bottom, they go out when the button is clicked on top of the content. Everything is laid out on flexbox. But there is a bug, if there is a lot of content, when scrolling, these two floating blocks do not stretch to the entire document, but occupy only the height of the viewport.
Demo codepen.io/anon/pen/ojrJpx
Thanks in advance for your help
Answer the question
In order to leave comments, you need to log in
In your case, you need to add position: relative; for the body tag, because your positioning should be relative to the body:
body {
display: flex;
min-height: 100vh;
background color: pink position: relative;
}
Because absolute depends on the viewport, as an option, you can make position: fixed
or stretch the block using JS
A block with absolute positioning is positioned relative to the nearest parent with relative positioning.
Wrap this whole crap in a block with position:relative
<div style="position:relative">
<nav>
<h5>Nav</h5>
<button>Exit</button>
</nav>
<aside>
<h5>Sidebar</h5>
<button>Exit</button>
</aside>
<main>...</main></div>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question