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 8661393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:29:13+00:00 2026-06-12T16:29:13+00:00

Im using this script: <script> $(function() { var offset = $(#menu_border).offset(); var topPadding =

  • 0

Im using this script:

<script>
    $(function() {
        var offset = $("#menu_border").offset();
        var topPadding = 20;
        $(window).scroll(function() {
            if ($(window).scrollTop() > offset.top) {
                $("#menu_border").stop().animate({
                    marginTop: $(window).scrollTop() - offset.top + topPadding
                });
            } else {
                $("#menu_border").stop().animate({
                    marginTop: 0
                });
            };
        });
    });
    </script>

It makes my $menu_border following the window as the user scrolls. The problem is, I have a div “under” this one and when the user (with a screen of lesser resolution then 1080) scrolls to the bottom of the page, this script just keeps on pushing #menu_border down, making the page longer and longer.

So the question is; Is there a simple way to make it stop at a certain point? The best thing would be inside a container (#container_div in this case).

Hope I made myself understood.

Best regards!

  • 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-06-12T16:29:15+00:00Added an answer on June 12, 2026 at 4:29 pm

    You need to stop adding to the margin the moment value of $(window).scrollTop() combined with height of the #menu_border exceeds height of the body.

    This one is of top of my head, and I didn’t try it live, but altering your first condition to be:

    if ($(window).scrollTop() > offset.top && 
        ($(window).scrollTop() + $('#menu_border').outerHeight() <=  $('BODY').height()) {
    

    instead of

    if ($(window).scrollTop() > offset.top)
    

    should do the trick. Depending on whether you have padding on #menu_border you’re maybe want to use $('BODY').outerHeigh() instead of $('BODY').height().

    Let me know if you did it.

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

Sidebar

Related Questions

Hay, i'm using this script function preloader(images){ var i = 0; imageObj = new
I'm using this for my scroll transition between a top and bottom div: <script
i'm using this jquery script: $(document).ready(function(){ $(#basketItemsWrap li:first).hide(); $(.productPriceWrapRight a img).click(function() { var productIDValSplitter
I'm using this script below for loading a hidden div, inside another: $(document).ready(function(){ $(function()
Recently I've been looking at opening a tab using this script: $('.tofour').click(function() { //
Using this piece of code in the head of a page: <script type=text/javascript> function
When using this code: <script> $(document).ready(function () { $.getJSON(http://twitter.com/statuses/user_timeline/USERNAME.json?callback=?, function(data) { if(data[0].text.length > 107)
I'm using this code: <script> $(document).ready(function () { $.getJSON(http://twitter.com/statuses/user_timeline/USERNAME.json?callback=?, function(data) { $(.show_tweet).html(data[0].text); }); });
After loading a PHP template (using jQuery's load function), this simple script won't make
This is the file I'm using $.load() to load into DOM: <script type=text/javascript> $('.close').click(function()

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.