devboell
devboell

Reputation: 1190

scrollable div with fixed element inside

please have a look at this jsfiddle: http://jsfiddle.net/devboell/kjFps/

I need to make a div, whose contents will overflow both horizontally and vertically. There also needs to be an element that will scroll along horizontally, but remain fixed vertically.

To explain the code:

There is also a further requirement, and although I don't want to ask two questions at the same time, I think I should mention it because it might influence the solution for this problem. The requirement is that the vertical scrollbar should alway be visible, and not only when you scroll all the way to the right, like it does now.

Thanks in advance!

Upvotes: 0

Views: 1307

Answers (1)

Shevchenko Viktor
Shevchenko Viktor

Reputation: 5416

I have faced the similar problem, and can say that according to specification it ia impossible to have div scrollable horizontaly, and fixed vertically at once time.

The solution I used is like: 1. set inside element position to absolue;

$.('container').on('scroll', function(){

$('.inside-element').css('left', $.('container').scrollLeft())

})

Upvotes: 1

Related Questions