Flex Layout with fixed position (no scrolling) sidebar

Windwalker

I have a layout with left and right canvas sidebars, enclosing the Main content area in the middle.

The sidebars and main content are flex items, positioned in a flex layout left to right.

The sidebars contain menus and meta links.

My question is: when scrolling the content area, is it possible to leave the sidebars in fixed position, such that they stay in top position and do 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;
}
user3576508

Please look at the similar question with provided solution: How to simulate 'position:fixed' behavior on Flexbox-aligned sidebar.

According to your code you can also wrap your 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 to #canvas-left */
}

Here is an example of your code with fixed left sidebar: http://jsfiddle.net/8hm3849m/. Note that this trick won't provide you proper flexible grid for sidebars, width of the wrapper should be fixed (or set dynamically via JavaScript).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Flex Layout with fixed position (no scrolling) sidebar

From Dev

#sidebar position:fixed at certain scrolling

From Dev

Position fixed sidebar with overflow scroll not scrolling to bottom

From Dev

Fixed SVG position in scrolling Flex item

From Dev

debug lag of calculate margin top for Position fixed sidebar scrolling to bottom

From Dev

Position absolute but with fixed scrolling

From Dev

Flex Layout Fluid and Fixed Width

From Dev

CSS: 3 Columns Layout with Fixed Sidebar Navigation

From Dev

Bootstrap 4: Fixed position sidebar overlapped by the content

From Dev

How to make custom sidebar position fixed

From Dev

Horizontal scrolling not working when position absolute/fixed

From Dev

How to disable background content scrolling in position fixed

From Dev

macgap scrolling issue when position fixed

From Dev

Fixed position element is flashing in Chrome when scrolling

From Dev

JQuery Position:Fixed 'NAVBAR' by scrolling the page

From Dev

Scrolling with a button which should have a fixed position

From Dev

How to detect scrolling in div when position is fixed

From Dev

Overflow scrolling not working on position fixed element iOS

From Dev

How to Stop Jumping Position fixed element on scrolling

From Dev

How to Stop Jumping Position fixed element on scrolling

From Dev

JQuery Position:Fixed 'NAVBAR' by scrolling the page

From Dev

macgap scrolling issue when position fixed

From Dev

Background scrolling behind position:fixed; on iOS

From Dev

Flex layout is not honoring width of fixed columns

From Dev

Flex css layout with fixed and variable elements

From Dev

Fixed position element inheriting width of flex item

From Dev

My sidebar is fixed no matter what. How do I make scrolling possible with the sidebar?

From Dev

Full height layout with collapse and fixed sidebar on bootstrap 3

From Dev

How to overlay a flex container with fixed position over another flex container?

Related Related

  1. 1

    Flex Layout with fixed position (no scrolling) sidebar

  2. 2

    #sidebar position:fixed at certain scrolling

  3. 3

    Position fixed sidebar with overflow scroll not scrolling to bottom

  4. 4

    Fixed SVG position in scrolling Flex item

  5. 5

    debug lag of calculate margin top for Position fixed sidebar scrolling to bottom

  6. 6

    Position absolute but with fixed scrolling

  7. 7

    Flex Layout Fluid and Fixed Width

  8. 8

    CSS: 3 Columns Layout with Fixed Sidebar Navigation

  9. 9

    Bootstrap 4: Fixed position sidebar overlapped by the content

  10. 10

    How to make custom sidebar position fixed

  11. 11

    Horizontal scrolling not working when position absolute/fixed

  12. 12

    How to disable background content scrolling in position fixed

  13. 13

    macgap scrolling issue when position fixed

  14. 14

    Fixed position element is flashing in Chrome when scrolling

  15. 15

    JQuery Position:Fixed 'NAVBAR' by scrolling the page

  16. 16

    Scrolling with a button which should have a fixed position

  17. 17

    How to detect scrolling in div when position is fixed

  18. 18

    Overflow scrolling not working on position fixed element iOS

  19. 19

    How to Stop Jumping Position fixed element on scrolling

  20. 20

    How to Stop Jumping Position fixed element on scrolling

  21. 21

    JQuery Position:Fixed 'NAVBAR' by scrolling the page

  22. 22

    macgap scrolling issue when position fixed

  23. 23

    Background scrolling behind position:fixed; on iOS

  24. 24

    Flex layout is not honoring width of fixed columns

  25. 25

    Flex css layout with fixed and variable elements

  26. 26

    Fixed position element inheriting width of flex item

  27. 27

    My sidebar is fixed no matter what. How do I make scrolling possible with the sidebar?

  28. 28

    Full height layout with collapse and fixed sidebar on bootstrap 3

  29. 29

    How to overlay a flex container with fixed position over another flex container?

HotTag

Archive