Search code examples
javascripthtmlcsslayoutscroller

How to fix side bar and header using CSS for JS & jQuery Scroller


I have this layout and I want to make the left sidebar, right sidebar and the header fixed.

enter image description here

This is my css :

    #container {
        padding-left: 200px;      /* LC fullwidth */
        padding-right: 190px;     /* RC fullwidth + CC padding */
    }

    #container .column {
        position: relative;
        float: left;
    }

    #center {
        padding: 10px 20px;       /* CC padding */
        width: 100%;
        overflow-x:hidden;
    }

    #left {
        width: 180px;             /* LC width */
        padding: 0 10px;          /* LC padding */
        right: 240px;             /* LC fullwidth + CC padding */
        margin-left: -100%;
    }

    #right {
        width: 130px;             /* RC width */
        padding: 0 10px;          /* RC padding */
        margin-right: -100%;
    }

    #footer {
        clear: both;
    }

& the code is here

After this step, I want to add nanScrollerJS to the right side bar.

I'm not familiar with CSS


Solution

  • Is this what you were trying to do?

    Fiddle

    I've erased almost all of your code and replaced it with new code.

    #fixed

    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    

    #center

    margin-top: 32px; /* Header height */
    padding: 10px 20px; /* CC padding */
    box-sizing: border-box;
    border-left: 200px solid black; /* LC width including padding */
    border-right: 150px solid black; /* RC width including padding */
    

    #left

    width: 180px; /* LC width */
    padding: 0 10px; /* LC padding */
    float: left;
    

    #right

    width: 130px; /* RC width */
    padding: 0 10px; /* RC padding */
    float: right;
    

    #footer

    position: relative;
    z-index: 1;