As it was already answered (How can I have a position: fixed; behaviour for a flexbox sized element?) absolutely/fixed positioned boxes are taken out of the normal flow of Flexbox-aligned elements. But how can I at least simulate position: fixed
behavior of, say, width: 300px; height: 100vw
element?
Here is a demo (http://codepen.io/anon/pen/ZGmmzR) of initial layout with sidebar on the left and content block on the right. I would like nav
act like position: fixed
element following user's scroll across the page. I know how to do it without Flexbox. In the first place I would consider pure CSS solution without using JavaScript. Thank you!
Edit:
A solution that somehow feels less hacky could be to make the container (
.wrapper
) as tall as the screen, and only add scrolling to the main<section>
element:http://codepen.io/Sphinxxxx/pen/WjwbEO
Original answer:
You could simply put everything inside
<nav>
in a wrapper (here:nav-wrapper
), and then fix that wrapper:http://codepen.io/anon/pen/PqXYGM