-2

In the Facebook News Feed, the side bar (containing ads, etc.) isn't fixed all the time. How do you do this? You could do

<div style="position:fixed"></div>

But how could you tell it to change back and forth according to your wish?

T.J. Crowder
  • 879,024
  • 165
  • 1,615
  • 1,639

1 Answers1

1

If you are happy to do it with jQuery:

$("#sideBar").css("position", "fixed");

and then to change it back:

$("#sideBar").css("position", "");
paul
  • 20,643
  • 1
  • 48
  • 53
  • +1 I missed the jQuery tag, and you beat me by a few seconds. :-) – T.J. Crowder Apr 17 '13 at 12:03
  • I think the question is about the whole process involved in this behavior of an element. He want the entire script, including scroll events and others.. that's why I voted down his question – Mihai Matei Apr 17 '13 at 12:10
  • @MateiMihai in that case: http://stackoverflow.com/questions/257250/what-is-the-simplest-jquery-way-to-have-a-positionfixed-always-at-top-div – paul Apr 17 '13 at 12:15