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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:46:53+00:00 2026-05-30T07:46:53+00:00

I have a slider that bounces back and forth between divs when you click

  • 0

I have a slider that bounces back and forth between divs when you click on a link. It works all the way up until you add overflow: hidden, and then everything breaks!

I created a demo for anyone to look at. You’ll notice it works, but try to add overflow: hidden to the .clickWrapper div to hide the divs sliding in and it breaks. It will scroll past other divs when you click on the one you want.

http://jsfiddle.net/z67tZ/

$(function() {
    $(".clickIt a").click(function() {
        var linked = $(this).attr("href");
        var pos = $(linked).position();
        $(".clickSlider").stop().animate({
            left: -pos.left,
        }, 500);
    });
});
<div id="wrapper">
    <div class="clickIt">
        <a href="#one">one</a>
        <a href="#two">two</a>
        <a href="#three">three</a>
    </div>
    <div class="clickWrapper">
        <div class="clickSlider">
            <div id="one">one</div>
            <div id="two">two</div>
            <div id="three">three</div>
        </div>
    </div>
</div>
#wrapper {margin: 0 auto; width: 200px;  }
.clickWrapper {background:red; position:relative; overflow:hidden; background-color: #CCC; height: 200px; }
.clickSlider { position: relative; width: 600px; }
#one, #two, #three { float: left; width: 200px; }
  • 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-30T07:46:54+00:00Added an answer on May 30, 2026 at 7:46 am

    Try preventing the default hashchange, like so:

    $(".clickIt a").click( function (e) {
        e.preventDefault();
        var linked = $(this).attr("href"),
            pos = $(linked).position().left;
    
        $(".clickSlider").stop().animate({left: -pos}, 500 );
    });
    

    ​
    FIDDLE

    I’m not completely sure why this happens ??

    My 2cents is that it is the browsers native function of trying to scroll to any anchor that matches the href attribute that is clicked when preceeded by a hash.

    This causes the position to be messed up as the page tries to scroll down to the element that has the same anchor as the href.

    When using a href value with a hash and wich matches an elements ID for anything other than scrolling, adding preventDefault (or return false for that matter even though there is no need to stop any propagation here) is always a good idea to avoid freaky bugs like this one.

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

Sidebar

Related Questions

I have a slider that rotates between different divs nicely with the following code:
I have a vertical slider that works well except when it needs to scroll
I have a slider that when you click next and previous, the images slide
I have a content slider script that works fine for me in FF, IE
I have a slider that when clicked, animates a div vertically, then goes back
Let's say I have a slider that can go between 0 and 1. The
I have a slider that slides images across on the click of a button
I have a StackPanel inside of a ScrollViewer. I have a slider that does
I have this menu structure that is used to navigate through content slider panels.
I have a script that opens Powerpoint from my application and exports all slides.

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.