Creating a FIXED element with re-size and scroll detection using YUI dom and event

We have all see them and some of us love them. It’s those elements that seem to float on the page like hovering little angels. Ok enough with the sappy crap…down to business. So you need to create a browser independent simple script to position an element on a page. I put together a simple script that will handle such a task and is flexible enough for even a newbie to configure.

In this example my task is to create a footer element that will stay on the bottom of the browser window during re-size and scroll events.View the completed project\n

CSS

First you will need to specify the position and size of your element.


HTML

Assign your element an ID!


Javascript

Insert the following code to the bottom of the page just before the body tag.
In this example I am using the YUI Loader to speed up deployment of my examples. You do not need to user YUI Loader but remember you will need to load the yahoo, dom and event scripts from the YUI Library in order for this to work.


  • Technorati Favorites
  • DZone
  • Facebook
  • Slashdot
  • Yahoo Buzz
  • Twitter
  • Yahoo Bookmarks
  • Reddit
  • Digg
  • MySpace
  • StumbleUpon
  • LinkedIn
  • Delicious
  • Blogger Post
  • Bebo
  • Google Reader
  • Share/Bookmark
Leave a comment

2 Comments.