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

  • Home
  • SEARCH
  • 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 6768221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:02:58+00:00 2026-05-26T15:02:58+00:00

How do I put a div position: fixed; bottom: 0; until the scroll reaches

  • 0

How do I put a div position: fixed; bottom: 0; until the scroll reaches the footer, then it’s position: absolute; bottom: 0; of the content div.

I want the div to always stick to the bottom of the viewport, then stick to the bottom of the content div and not cover up my footer.

Bonus points for compass/sass solution!

  • 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-26T15:02:59+00:00Added an answer on May 26, 2026 at 3:02 pm

    In this fiddle (I used yours as a base, forked it though) you can see a working example of what you want, with a supposed footer height of 100px.

    Here’s the JS needed:

    $(window).scroll(function () {
        if ($(window).scrollTop() + $(window).height() >= $(document).height() - 100) {
            $('div#scrolled').css({'bottom' : '100px'});
        } else {
            $('div#scrolled').css({'bottom' : '0px'});
        }
    });
    

    It checks, on scroll, if the scroll reached the bottom plus 100 pixels, and if so, it sets the bottom of the fixed element to 100px. The bad point is that it’s not progressive, and the fixed element jumps when the footer appears. You cant just remove the 100 in the if statement if you want the footer to pop when the user reaches the absolute bottom: if ($(window).scrollTop() + $(window).height() >= $(document).height()) { ...

    UPDATE:

    Here is the “progressive” version of the above code.

    $(window).scroll(function () {
        if ($(window).scrollTop() + $(window).height() >= $(document).height() - 100) {
            var bottom = 100 - ($(document).height() - ($(window).scrollTop() + $(window).height())) + "px";
            $('div#scrolled').css({'bottom' : bottom});
        } else {
            $('div#scrolled').css({'bottom' : '0px'});
        }
    });
    

    Now, instead of changing the bottom to 100px whenever the user scroll is under 101px from the bottom, it calculates the position the fixed element should have depending on the scroll

    Hope it helps!

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

Sidebar

Related Questions

I have a div which is position:fixed so that it it always in the
In jQuery, how do you make it so a DIV will stay put until
There is a large absolute positioned Div with lots of absolute positioned content in
I have a few div boxes that are using position:fixed and I use a
I want to put a red rectangular <div> element over my webpage so that
This is my html5 markup <div id="header"> </div> <div id="content"> </div> <div id="footer"> </div>
Is there a way to create a fixed position window (a transparent Div?)centered in
I've written a web page where the content sits within a fixed-width, centered div,
I want my div to show on top of everything I put 100% width
I have the following div layout: Everything is fine when I put normal txt

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.