html - Flex Layout with fixed position (no scrolling) sidebar -


i have layout left , right canvas sidebars, enclosing main content area in middle.

the sidebars , main content flex items, positioned in flex layout left right.

the sidebars contain menus , meta links.

my question is: when scrolling content area, possible leave sidebars in fixed position, such stay in top position , not scroll down?

js fiddle: http://jsfiddle.net/windwalker/gfozfpa6/2/

html:

<div class="flexcontainer">     <div class="flexitem" id="canvas-left">         <p>this content should not scroll</p>     </div>     <div class="flexitem" id="content">         <div>             <p>scrolling content</p>         </div>     </div>     <div class="flexitem" id="canvas-right">         <p>this content should not scroll</p>     </div> </div> 

css:

.flexcontainer {     display: flex;     flex-direction: row;     min-height: 100%;     align-items: stretch; } .flexitem {     display: flex; } #canvas-left {     background: yellow;     order: -1;     flex: 0 0 57px; } #content {     background: green;     order: 1;     padding: 1rem; } #content div {     display: block; } #canvas-right{     background: blue;     order: 2;     flex: 0 0 57px; } 

please @ similar question provided solution: how simulate 'position:fixed' behavior on flexbox-aligned sidebar.

according code can wrap inner content in "position: fixed" wrapper:

<div class="flexitem" id="canvas-left">     <div class="fixed">         <p>this content should not scroll</p>     </div> </div> 

and add proper styling in css:

.fixed {     position: fixed;     width: 57px; /* according #canvas-left */ } 

here example of code fixed left sidebar: http://jsfiddle.net/8hm3849m/. note trick won't provide proper flexible grid sidebars, width of wrapper should fixed (or set dynamically via javascript).


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -