views:

428

answers:

3

Hello, I'm trying to use jQuery EasySlider to carousel, however, when I specify a number in percentage for the width of the div container, the container fails to deliver content.

Am I to assume that it is incapable of dealing with percentages?

A: 

In EasySlider 1.7 It should work just fine. The relevant code in the plugin is:

var w = $("li", obj).width(); 

.width() in jQuery returns the value in pixels even if it is specified in the CSS as a percentage. Whether you specify percentage or pixels, it's effectively the same.

Which version of EasySlider are you using?

cmcculloh
I'm using 1.7 :)http://cssglobe.com/post/5780/easy-slider-17-numeric-navigation-jquery-slider
Shamil
A: 

Use this ancient Math equation:

function getPercentage(percent, original)
{
    return ((percent/100) * original))|0;
}

Customize the code as you want, It just gets the desired percentage of any number!.

Omar Dolaimy
That will work for one time, but doesn't if the div changes its size.
Pekka
yeah, won't always work :(
Shamil
A: 

Does the container div have floating children? If true, that's why the div doesn't show any content (floating elements are taken out of the document flow and thus out of the parent element, which in turn will collapse to 0 width when there are no no-floating children).

MysticEarth
What do you mean by floating children? Div -> ul -> li
Shamil
CSS floating. Floating can be set to left, right or none. It is often used for styling. For more info, this should help: http://css.maxdesign.com.au/floatutorial/. Remember: div's can float, ul's can float and even li's can float.
MysticEarth