Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5979853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:43:05+00:00 2026-05-22T21:43:05+00:00

In jQuery, how do you make it so a DIV will stay put until

  • 0

In jQuery, how do you make it so a DIV will stay put until the user scrolling down would make it no longer visible (at which point it sets its own CSS position to “fixed”)? It’s a trick I see a lot, just not sure how it’s done.

Example: http://www.yelp.com/search?find_desc=sushi&ns=1&find_loc=San+Francisco%2C+CA

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:43:06+00:00Added an answer on May 22, 2026 at 9:43 pm

    Here’s a quick example of some code:

    var standardPosition = $('div').offset().top;
    
    $(window).scroll(function() {
        if ($(this).scrollTop() > standardPosition) $('div').css('position','fixed');
        else $('div').css('position','relative');
    });
    

    It’s important to store the starting position somewhere, so you know when you’ve scrolled up far enough to restore it to whatever position it was in.

    http://jsfiddle.net/qC6HB/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a simple JQuery button from a div which will change
I have a multiple checkboxes. Checking any of them will make a div visible.
I'm currently using jQuery to make a div clickable and in this div I
How exactly do you make an auto-refreshing div with JavaScript (specifically, jQuery)? I know
How do I make an element, e.g. a div, draggable using jQuery?
Which is the best unobtrusive and lightweight jquery solution to make tab? Although Jquery
I want to make a form that will use jquery to submit a list
How can I using jQuery make the image inside of a div change to
I want to make the div's expand/collapse on the jquery click function I have
Does anyone know of any jQuery Script that will keep a div centered in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.