SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Evangelist
    Join Date
    Jan 2005
    Posts
    425
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to do this.....

    Sorry I can't explain this easily with words, so I got some screen captures to help. I want to do something on my site similar to the AdWords help block that sits towards the top of the page but when you scroll down it stays at the top.

    Eg, when looking at the top of the page:


    Now, I have scrolled down the page, the help section stays "docked" at the top:


    I'm not sure if this is just CSS, or involves JavaScript.

    I'm wanting to dock a form like this, in the left column, that is contained in a div with id="leadsbox".

    Thanks

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,629
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You seem to have omitted the screen captures.
    Ian Anderson
    www.siteguru.co.uk

  3. #3
    SitePoint Evangelist
    Join Date
    Jan 2005
    Posts
    425
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Really? Screen captures are showing for me.

  4. #4
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,031
    Mentioned
    152 Post(s)
    Tagged
    2 Thread(s)
    You can use CSS's position: fixed for this
    Note that that doesn't work in IE6, but there are forkarounds for that.

    Alternatively you could use a javascript function that updates the position of the block when scrolling. That also works in IE6. For an example (and there a many others if you search for them using your favorite search engine): here.

    PS. Screen captures are showing for me too
    Rémon - Hosting Advisor

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  5. #5
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,629
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I'm viewing this from the office - I guess the captures are blocked by the firewall.
    Ian Anderson
    www.siteguru.co.uk

  6. #6
    SitePoint Evangelist
    Join Date
    Jan 2005
    Posts
    425
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ScallioXTX View Post
    You can use CSS's position: fixed for this
    Note that that doesn't work in IE6, but there are forkarounds for that.

    Alternatively you could use a javascript function that updates the position of the block when scrolling. That also works in IE6. For an example (and there a many others if you search for them using your favorite search engine): here.

    PS. Screen captures are showing for me too
    Thanks but does that CSS position fixed work in this scenario? Initially with no scroll the DIV displays about 100 pixels from the top of the top browser edge.

    As you scroll down 0-100 pixels the div gets closer to the top of the browser edge (like a normal div would), when you scroll 100+pixels down, then the div stays docked with the very top of the top browser edge. And the reverse happens when you scroll back up.

    Makes more sense? Sorry hard to explain

  7. #7
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,031
    Mentioned
    152 Post(s)
    Tagged
    2 Thread(s)
    Yes that makes sense.
    I wouldn't know how to do that using CSS (maybe someone else does?), so you probably need javascript
    Rémon - Hosting Advisor

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  8. #8
    SitePoint Evangelist
    Join Date
    Jan 2005
    Posts
    425
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, any other ideas?

  9. #9
    SitePoint Evangelist
    Join Date
    Jan 2005
    Posts
    425
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anybody?

  10. #10
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,629
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I think your search terms are onscroll and scrollTop.
    Ian Anderson
    www.siteguru.co.uk


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
  •