L
L
lavezzi12015-11-27 16:36:52
css
lavezzi1, 2015-11-27 16:36:52

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

4 answer(s)
B
BohdanK, 2015-11-27
@BohdanK

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; }

Y
Yaroslav Samardak, 2015-11-27
@yaroslav_samardak

Because absolute depends on the viewport, as an option, you can make position: fixedor stretch the block using JS

A
Alexander Melnichenko, 2015-11-27
@alex87melnichenko

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>

D
Dmitry Khristoev, 2015-11-27
@Haoss

why ask twice?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question