Forum Moderators: not2easy

Message Too Old, No Replies

Fixed position inside a scrollable div

         

rdunne

8:09 pm on Feb 9, 2011 (gmt 0)

10+ Year Member



I have a div on a page which is scrollable using overflow auto. Inside this div I have a button which I want fixed so that I doesn't scroll with the rest of the div content. Any way to achieve this?

rainborick

5:15 am on Feb 10, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It's tough to advise you without more details; for example, where do you want the button to appear in relation to the scrollable content?

Generally, I find that the best solution to having disparate elements positioned in relation to each other requires a parent containing element (like a <div>) to provide a position reference for those elements. Set the containing element to "position:relative; top:0; left:0;", with adequate width and height to hold everything, and you can set the contained elements to "position:absolute" and position them as you like.