1

I am not sure if this is possible, without some JavaScript at lest. What i am trying to do is keep the content in the sidebar within the viewport for horizontal scroll but not vertical scroll (this issue occurs on low resolutions). I have put together a quick js fiddle to demonstrate the issue http://jsfiddle.net/evkhvvdr/ any input is greatly appreciated.

Here is the CSS or view the js fiddle

body {
    position: relative;
    margin: 0;
}
.sidebar {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 100px;
    background: blue;
    left: 0;
}
.sidebar-inner {
   position: fixed;
   left: 0;
}
.content {
   width: 1400px;
   background: pink;
   height: 2000px;
}
luke mclean
  • 358
  • 1
  • 7
  • possible duplicate of [Position element fixed vertically, absolute horizontally](http://stackoverflow.com/questions/3303173/position-element-fixed-vertically-absolute-horizontally) – Ian Sep 28 '14 at 22:21

1 Answers1

1

You can fix sidebar on screen, but put it under content with z-index, so when you scroll, you scroll only content, sidebar is still on screen, but under the content.

body {
    margin: 0;
}
.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 100px;
    background: blue;
    z-index: 0;
}
.sidebar-inner {
    width: 100px;
    position: relative;
    left: 0;
}
.content {
    position: absolute;
    width: 1400px;
    background: pink;
    height: 2000px;
    margin-left: 100px;
}
Peter Tretyakov
  • 3,380
  • 6
  • 38
  • 54