Give help. Get help.

  • # April 10, 2013 at 6:54 am

    I’m creating my own slider and I need some help making it responsive. Right now it works with the responsive part on the first slide, but when I go to the next slide (in this case, any li that is NOT first child) the positioning and width’s of the li’s doesn’t add up and everything gets wrong.

    It’s hard to explain and I’d love if anyone could take a look here:

    I have a wrapper with a width of 100% and every li’s width gets set to the width of the wrapper of 100%. If you don’t understand what I’m after try go to the page, resize your browser on the first slide, that is how I want it to work on all the other slides as well but I need some ideas on how to do it!


    #sliderContainer #slider {width: 100%; height: 100%; float: left; overflow: hidden; border: solid 1px #000;}
    #slider ul {width: 10000px; height: 100%; float: left; display: inline; list-style: none;}
    #slider ul li {width: auto; height: 100%; float: left; background-color: #fff; text-align: center;}
    #slider li img {max-width: 1140px; height: 100%;}


    var slideLiWidth = $(‘#slider’).width(),
    slideUl = $(‘#slider ul’),
    slideLi = $(slideUl).find(‘li’),
    slides = $(slideLi).length,
    slideNav = $(‘.slideNav’),
    current = 1;


    $(window).resize(function() {
    var slideLiWidth = $(‘#slider’).width();
    }); {
    dir = $(this).data(‘dir’);

    function transition() {
    var slideLiWidth = $(‘#slider’).width();
    if (dir === ‘next’ && current < slides) {
    slideUl.transition({x: ‘-=’+slideLiWidth}, 500, ‘ease’);
    else if (dir === ‘back’ && current > 1) {
    slideUl.transition({x: ‘+=’+slideLiWidth}, 500, ‘ease’);

    # April 11, 2013 at 10:55 am

    Change li position after resize window (image should be always on center).


    $(window).resize(function() {
    slideLiWidth = $(‘#slider’).width();

    /* center your current slide */
    var transform = slideLiWidth*(current-1);
    slideUl.transition({x : ‘-‘ + transform+’px’});

    I hope it resolves your problem.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.