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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:23:30+00:00 2026-06-06T20:23:30+00:00

I am trying to builder a nav slider, which is like an arrow sliding

  • 0

I am trying to builder a nav slider, which is like an arrow sliding under the navigation links. I would like to animate it to the center of a div.

This is my nav code:

<nav>

        <ul class="tabs">
            <li id="tab1"><a href="#">Cursussen</a></li>
            <li id="tab2"><a href="#">Resultaten</a></li>
            <li id="tab3"><a href="#">Inbox</a></li>
            <li id="tab4"><a href="#">Profiel</a></li>
            <li id="tab5"><a href="#">Aanbod</a></li>
        </ul>

        <a id='slider'><img src="img/arrow.png"></a>

</nav>

And this is the jquery i use to animate:

$(function(){
        $('li#tab1').click(function(evt) {
            evt.preventDefault();
            $('#slider').animate({
                left : '32'
            });
        });
});

I was thinking I could create a var like the following, which calculates the width of the div I want to move to the center of. But I don’t exactly know how to write the code for the animation part.

var w = '$(#slider).parent().width()'/2
  • 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-06T20:23:31+00:00Added an answer on June 6, 2026 at 8:23 pm

    Please try this js fiddle:

    http://jsfiddle.net/Q4efa/2/

    In particular, I used the following method:

    $('ul.tabs li').click(function(event){
    
        event.preventDefault();
    
        var ulOffsetLeft = $('ul.tabs').offset().left;
        var currentOffset = $(this).offset().left;
    
        var delta = currentOffset - ulOffsetLeft;
    
        $('#slider').clearQueue().animate({'margin-left': delta});
    
    });​
    

    UPDATE: I added some automatic padding calculation to this new fiddle here:

    http://jsfiddle.net/Vt2dv/8/

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

Sidebar

Related Questions

I'm using Add-on Builder Beta (Firefox) and I'm trying to do something like this:
I'm trying to build game like http://games.yahoo.com/game/bricks-breaking in actionscript 3 (flash builder). I am
I'm trying to build a continuous builder for my latex document, which calls latex
We are trying to build a SQL query builder that would allow users to
I am trying to do a basic tutorial like MXML Application on Flash Builder
I'm trying to implement a custom form builder, similar to those provided by Wufoo
I'm trying to avoid using Interface Builder as much as possible. At the moment
I am trying to create a builder for my form fields and I come
I'm trying to build a C++ program with borland C++ Builder V5.5. Everything works
I'm trying to create an application in interface builder, and I'm having a problem.

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.