How do you make a div follow as you scroll?

前端 未结 6 1974
孤街浪徒
孤街浪徒 2020-12-23 16:33

I have a div on the left hand side which includes the business hours and weather. I would like that div to scroll down and up according to how the user scrolls. So it would

6条回答
  •  醉酒成梦
    2020-12-23 16:35

    You can use the fixed CSS position property to accomplish this. There is a basic tutorial on this here.

    EDIT: However, this approach is NOT supported in IE versions < IE7, and only in IE7 if it is in standards mode. This is discussed in a little more detail here.

    There is also a hack, explained here, that shows how to accomplish fixed positioning in IE6 without affecting absolute positioning. What version of IE are you targeting your website for?

提交回复
热议问题