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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:39:12+00:00 2026-06-12T18:39:12+00:00

I got a div that expands on a click, sometimes its at the bottom

  • 0

I got a div that expands on a click, sometimes its at the bottom of the page and its close to the bottom. What i want is that when its close to the bottom that it should scroll down just below it.

My solution so far is below. I get how to calculate the values and animate an all but i just dont get why my script wants to scroll to the bottom of the page, it just slams it to the bottom. Any ideas?

EDIT
Doh ofcause its gone scroll to the bottom. Question is how do i scroll so its just below my div by 10px? Im not suppose to say scrollTop: total

jquery

       var $ediv = $this.parent('div').find('.order-expand-row');
       var hDiv = $ediv.outerHeight();
       var oDiv = $ediv.offset().top;
       var wHeight = $(window).height();
       var total = hDiv + oDiv + 10;

       if (total >= wHeight) {                                   
          $('html, body').animate({ scrollTop: total }, 600);
       }
  • 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-12T18:39:13+00:00Added an answer on June 12, 2026 at 6:39 pm

    Well a cup of tea can do magic 😉

    solved it by subtracting the wHeight from total, that got me the value i need to scroll to.
    To clear it, what I needed was the position where i wanted to scroll to stop not where it should scroll to.

       var $ediv = $this.parent('div').find('.order-expand-row');
       var hDiv = $ediv.outerHeight();
       var oDiv = $ediv.offset().top;
       var wHeight = $(window).height();
       var total = hDiv + oDiv + 10;
       var scrollTo = total - wHeight; //the scroll position
    
       if (total >= wHeight) {                                   
          $('html, body').animate({ scrollTop: scrollTo }, 600);
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ive got a div that i want to slide out on click using .show(slide,
I've got a div that I am appending to the page dynamically on click
I've got a div that I want to position at the bottom of the
I've got three columns inside of a div that is the full page width.
I've got a DIV #alerts_wrapper on my page that is being refreshed every 5
I've got a div that I want to position partially off-screen like so: div
I've got a div that is hidden on page load and stretches to 100%
Okay, I've got a page with a header div that stretches 100% wide, with
I've got a div that I would like to rotate about its y-axis (with
I got a floating header div that follows my scroll position. my problem is

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.