SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Sticky menu

  1. #1
    SitePoint Zealot s21825's Avatar
    Join Date
    Oct 2003
    Location
    Canada
    Posts
    162
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Sticky menu

    I'm trying to get build a navigation menu that will slide up/down a page as a user scrolls up/down. I've got a menu based on the Yahoo! User Interface (YUI) library but I can't seem to figure out how to get it to move down as the user scrolls.

    Can anyone give me a hand? Maybe just a simple example of getting a <div> with an id to slide down when scrolling ... then I can adapt that to my situation. I'd also love it if it used the YUI (but I'm not too fussy!)

    Thanks!
    s21825

  2. #2
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Something offhand:
    Code:
    function position_menu(){
    	var pos=50;  //y offset
    	if (window.innerHeight){
    		pos += window.pageYOffset
    	}else if (document.documentElement && document.documentElement.scrollTop){
    		pos += document.documentElement.scrollTop
    	}else if (document.body){
    		pos += document.body.scrollTop
    	}
    	document.getElementById('menu').style.top=pos+'px';
    	setTimeout('position_menu()',100);
    }
    Saul

  3. #3
    SitePoint Zealot s21825's Avatar
    Join Date
    Oct 2003
    Location
    Canada
    Posts
    162
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thanks

    Thanks, I'll get this a shot.
    s21825


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •