3

I'm trying to get jcarousel to work with an li width of 100%. i.e. whatever width the browser window has, that's the width of the li item and if the window is shrunk, the text will flow accordingly and still function as a slider.

Here is my fiddle...

http://jsfiddle.net/kirkbross/3FhcQ/38/

Kirk Ross
  • 6,413
  • 13
  • 61
  • 104

1 Answers1

0

I found that I had to use jQuery taken from the following sample:

http://sorgalla.com/jcarousel/examples/responsive/

$(document).ready(function() {
    var jcarousel = $('.carousel-stage');

    jcarousel
        .on('jcarousel:reload jcarousel:create', function () {
            var width = jcarousel.innerWidth();
            var height = jcarousel.innerHeight();

            if (width < 560) {
                jcarousel.jcarousel('items').css('width', width + 'px');
                jcarousel.jcarousel('items').css('height', (width*0.666) + 'px');
            } else {
                jcarousel.jcarousel('items').css('width', '600px');
                jcarousel.jcarousel('items').css('height', '400px');
            }

        })
});        

and the CSS - for connected carousels in this case

@media screen and (max-width: 660px) {
    .connected-carousels,
    .connected-carousels .stage,
    .connected-carousels .navigation,
    .connected-carousels .carousel-stage,
    .connected-carousels .carousel-navigation,
    .carousel-stage li img {
        width: 100%;
        height:auto;
    }
    .carousel-stage li img {
        padding: 0;
        margin: 0;
        vertical-align: top;
    }
    .connected-carousels .prev-stage, .connected-carousels .next-stage {
        width: 50%;
        height: 100%;
    }
    .jcarousel-clip-horizontal 
    {
        width: 100%;    
        overflow: hidden;
    }
}
Daniel Flippance
  • 7,734
  • 5
  • 42
  • 55