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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T00:23:30+00:00 2026-05-21T00:23:30+00:00

I have made use of var slideWidth = 420; to specify sliders width and

  • 0

I have made use of var slideWidth = 420; to specify sliders width and then $('#slideInner').css('width', slideWidth * numberOfSlides); to calculate all sliders width for long time and it was working fine with pixels

Problem

I need to use % and Jquery seems not to understand it.

// slider
   var currentPosition = 0;
   var slideWidth = 420; // Use quotes('') for %  
   var slides = $('.slide'); // for each image
   var numberOfSlides = 4; // slides.length: show all images 

   // Remove scrollbar in JS 
   $('.slidesContainer').css('overflow', 'hidden');

   // Wrap all .slides with #slideInner div

   slides.wrapAll('<div id="slideInner"></div>').css({'float' : 'left','width' : slideWidth});

   // Float left to display horizontally, readjust .slides width
   /* 
   Set #slideInner width equal to total width of all slides
   #slideInner wraps all of our slides that has a width equal to total width of all .slide div.

   Problem: It needs a fix variable to calculate width    

   */

    $('#slideInner').css('width', slideWidth * numberOfSlides);  
  • 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-21T00:23:30+00:00Added an answer on May 21, 2026 at 12:23 am

    Try something like this:

    // slider
    var currentPosition = 0;
    var slideWidthPct = 80; // this is a percent (between 0 and 100)
    var slides = $('.slide'); // for each image
    var numberOfSlides = Math.min(4, slides.length); // slides.length: show all images 
    var singleSlideWidth = slideWidthPct / numberOfSlides;
    
    // Remove scrollbar in JS 
    $('.slidesContainer').css('overflow', 'hidden');
    
    // Wrap all .slides with #slideInner div
    
    slides.wrapAll('<div id="slideInner"></div>').css({'float' : 'left','width' : "" + singleSlideWidth + "%"});
    
    // Float left to display horizontally, readjust .slides width
    $('#slideInner').css('width', "" + slideWidthPct + "%");  
    

    Working example based on your code: http://jsfiddle.net/7B8Bb/3/

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

Sidebar

Related Questions

I have made a registration program. Making use of mysql database. Can I still
So I have made a .dll containing some methods that I wish to use
I am trying to use file_get_contents.I have made sure that allow_url_fopen is enabled in
I use Acceleo in order to generate code with a model I have made.
I have finally made a production worthy app with play, and use the play
I have an application in which we use a hand-made build system.The reason for
Hello all i have made a tab menu in my sidebar (follow a tutorial),
I have made up the custom module as : YUI.add('util', function(Y) { Y.namespace('com.myCompany'); var
Hi I have made the following item renderer in mxml, but when I use
I have made simple example of using canvas and then I saw that my

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.