Floating div with boundaries

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
bemaitea
Forum Newbie
Posts: 9
Joined: Sun Jul 04, 2010 6:21 pm

Floating div with boundaries

Post 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
User avatar
PHPHorizons
Forum Contributor
Posts: 175
Joined: Mon Sep 14, 2009 11:38 pm

Re: Floating div with boundaries

Post 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
Post Reply