问题描述:

I want to add a fixed sidebar like in the picture below.

How is that possible?

Appreciate any suggestion.

Solution

网友答案:

used to this

fixed position

.sidebar{
position:fixed;
left:0;
width:250px; // width change to according your left bar side
top:0;
bottom:0;
}

Demo

网友答案:
.SomeClass { position: fixed }
网友答案:

This fiddle might solve your problem, with right column being flexible and left column fixed

http://jsfiddle.net/R5TZH/

<div class="container">
         <div class="columns">
         <div class="right-col">
             Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum
        </div>    
     </div>  
    <div class="left-col">
                <a class="selected" href="#">05 <br><strong>Today</strong></a>
                <a href="#">06 <br><strong>TOM</strong></a>
                <a href="#">07 <br><strong>MON</strong></a>
                <a href="#">08 <br><strong>TUE</strong></a>
                <a href="#">09 <br><strong>WED</strong></a>
                <a href="#">08 <br><strong>THU</strong></a>
                <a href="#">09 <br><strong>FRI</strong></a>
    </div>  
</div>      

CSS:

.container {
    width: 100%;
}

.left-col {
    background: none repeat scroll 0 0 #434345;
    float: left;
    margin-left: -100%;
    padding: 10px;
    width: 80px;
}

.left-col a {
    background: none repeat scroll 0 0 #FFFFFF;
    border-radius: 10px 10px 10px 10px;
    color: #000000;
    float: left;
    font-size: 18px;
    height: 50px;
    margin-bottom: 10px;
    padding: 10px;
    text-align: center;
    width: 60px;
}


.columns {
    float: left;
    width: 100%;
}


.right-col {
    margin-left: 100px;
    background:red;
    height:400px;
}
网友答案:

for fixed side bar, style

position:fixed;

this will do but not in chrome, so you may use this

position:absolute;
top:0;
left:0;
bottom:0;
width:180px;// you may change as per your requirement

this works in all browsers :)

Edit : updated fiddle with content div

http://jsfiddle.net/MarmeeK/nkprH/5/

I hope this will do, for more answer post some of your work in details, thank you

相关阅读:
Top