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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:13:55+00:00 2026-06-18T14:13:55+00:00

Been working on a personal site lately and using jQuery ScrollTop to animate my

  • 0

Been working on a personal site lately and using jQuery ScrollTop to animate my content div. But I’ve ran into a problem.

  • 1st: there is a strange padding in the top of every involved

  • 2nd: the scroll is not consistent, ie. it doesn’t scroll the same height every time.

You can see the page here: http://mnpwr.dk/v2/index.html

– I added a red border around, so it would be easier to see the problem.

The jQuery:

jQuery.noConflict();

jQuery(document).ready(function () {
    getHash();
});

// Keep track of our current state
currentSection = 1;

function getHash() {

    jQuery('.scroll').on('click', function () {
        // Get our new state
        var gethash = jQuery(this).attr('class').split(' ')[0];
        // Calculate the difference, with element height of 500px using formular dest = (newPows - currentPos) * elmHeight
        var scrollTop = (gethash - currentSection) * 500
        jQuery('#contentDiv').animate({
            scrollTop: scrollTop
        }, 500);

        return false;

    });

}
  • 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-18T14:13:56+00:00Added an answer on June 18, 2026 at 2:13 pm

    Just add in CSS

    p{
     margin:0px;
    }
    

    Hope this clarifies your ‘problem’

    Your next problem is that if you have elements which height is 500px, if you add a red border 1px than the element’s height will actually be 502 🙂
    So if you animate 500 by 500, the position will not be precise.

    Just a suggestion, use .position() to get an element position and animate scrollTop to that retrieved value

    LIVE DEMO

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

Sidebar

Related Questions

I've been working on my first WordPress site (yay!) and I'm using the new
I'm working on a personal project and I have been running into lots of
I have been working with Django as backend and using jQuery for the front
Been working on a personal add-in for VS 2008 and have been researching automation
I have been working with Visual Studio (WinForm and ASP.NET applications using mostly C#)
Ive been working on my personal page which is based on drupal. Ive noticed
I've just recently been studying JQuery to use on a personal website. Something I
I've been working on a personal website (so, time is not an issue here)
Context: As a personal learning project I've been working on a simple computer algebra
I've been working with databases for a long time but I'm new to query

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.