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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:02:34+00:00 2026-06-12T15:02:34+00:00

I have made a custom jQuery carousel from bits I have picked up off

  • 0

I have made a custom jQuery carousel from bits I have picked up off the net, but I cannot get it working correctly.

All that happens is that the carousel works but keeps sliding left. And after some debugging I found that the left of the carousel_ul keeps on subtracting by the image width but does not return to -960 like I believe it should.

I have seen a few articles on here about carousels but none that use the approach I am going for.

Here’s my code:

HTML:

<div id="carousel_container">
        <div id="carousel_inner">   
            <ul id="carousel_ul">
                <li>
                    <img src="http://static.shopify.com/s/files/1/0167/9164/t/5/assets/carousel-item-1.jpg?1321" alt="" />
                </li>
                <li>
                        <img src="http://static.shopify.com/s/files/1/0167/9164/t/5/assets/carousel-item-2.jpg?1321" alt="" />
                </li>
                <li>
                        <img src="http://static.shopify.com/s/files/1/0167/9164/t/5/assets/carousel-item-3.jpg?1321" alt="" />
                </li>
                <li>
                        <img src="http://static.shopify.com/s/files/1/0167/9164/t/5/assets/carousel-item-4.jpg?1321" alt="" />
                </li>
            </ul>                       
        </div>
    </div>

CSS:

    #carousel_ul {  
position:relative;  
left:-960px; /* important (this should be negative number of list items width(including margin) */  
list-style-type: none; /* removing the default styling for unordered list items */  
margin: 0px;  
padding: 0px;  
width:9999px; /* important */  
/* non-important styling bellow */  
padding-bottom:0px;  
}  

#carousel_ul li{  
float: left; /* important for inline positioning of the list items */  
width:960px;  /* fixed width, important */  
/* just styling bellow*/  
padding:0px;  
height:300px;  
background: #000000;  
margin-top:0px;  
margin-bottom:0px;  
margin-left:0px;  
margin-right:0px;  
}  

#carousel_ul li img {  
.margin-bottom:-4px; /* IE is making a 4px gap bellow an image inside of an anchor (<a href...>) so this is to fix that*/  
/* styling */  
cursor:pointer;  
cursor: hand;  
border:0px;  
}  

jQuery:

jQuery(document).ready(function ($) {
//rotation speed and timer
var speed = 2000;
var run = setInterval('rotate()', speed);   

 jQuery('#carousel_ul li:first').before(jQuery('#carousel_ul li:last'));
});

//a timer will call this function, and the rotation will begin :)  
function rotate() {
var item_width = jQuery('#carousel_ul li').outerWidth() ; 

//calculate the new left indent of the unordered list  
var left_indent = parseInt(jQuery('#carousel_ul').css('left')) - item_width;  

//alert(left_indent);

//make the sliding effect using jquery's anumate function '  
jQuery('#carousel_ul').animate({'left' : left_indent},{queue:false, duration:1000},function(){  

    //get the first list item and put it after the last list item (that's how the infinite effects is made) '  
    jQuery('#carousel_ul li:last').after(jQuery('#carousel_ul li:first'));  

    //and get the left indent to the default -960px  
    jQuery('#carousel_ul').css({'left' : '-960px'});  
});
}

It was butchered from a couple of examples.

As it happens I could not get any to work as I wanted.

  • 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-12T15:02:35+00:00Added an answer on June 12, 2026 at 3:02 pm

    The reason it is not working is because the animate function is not getting fired. By simply setting the duration only, the carousel will function correctly to your requirements.

    //make the sliding effect using jquery's anumate function '  
    jQuery('#carousel_ul').animate({'left' : left_indent}, 1000,function(){  
    
        //get the first list item and put it after the last list item (that's how the infinite effects is made) '  
        jQuery('#carousel_ul li:last').after(jQuery('#carousel_ul li:first'));  
    
        //and get the left indent to the default -960px  
        jQuery('#carousel_ul').css({'left' : '-960px'});  
    });
    

    Once you are happy with your carousel I would recommend refactoring it into a jQuery plugin or widget to allow for easy reuse.

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

Sidebar

Related Questions

I have two jQuery UI custom builds; they were made by different people from
I have made a custom sort of wrapper for the JQuery's Ajax function and
I have successfully made a custom control-slider, but it's not draggable. I tried searching
From the should be simple, but... files: Trying to get started with jQuery UI.
I have made custom .xml layout for ListView. Now it looks: But it isn't
I'm working on application where I have a custom made List View, with image
I have a web application made in ASP.Net. Well, I have a few jquery
I have made a custom UserControl i Vb.net (windows application). How can I add
i made one script from here but now i have problem with geting $_POST['file']
For MS CRM 2011 I have made custom workflow activity, but I'm not able

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.