Page 1 of 1

Floating div with boundaries

Posted: Sun Jul 11, 2010 1:24 pm
by bemaitea
Hello all,

I'm still fairly new to the whole world of programming, but I'm getting there slowly! Reading these boards is incredibly helpful.

Anyway, here is a simple query, or at least it looks simple on the surface...

I would like to have a floating div follow the user as they scroll the page. I have found the EXACT script that I need here: http://www.jtricks.com/javascript/navig ... ating.html

The only thing is I would like the floating menu to float within another div and not move from out side of that containing div. As the script is, the menu position is absolute relative to the browser. Is there a way to make the floating div absolute to the boundaries of a second containing div (ie main content div of 700px width)?

Thanks for any input! :D

Re: Floating div with boundaries

Posted: Mon Jul 12, 2010 7:09 am
by PHPHorizons
You can apply a style of position: relative; to the containing div. Then, a div inside of that relatively positioned div which has position: absolute; is positioned based on the position of the relatively positioned div.

I hope that helps. Cheers