Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Dynamic horizontal scroller

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 208
    Comment on it

    Hello All, The following code will help you to make dynamic horizontal scroller. This means that on adding content or images the width of the container automatically increases using jquery.
    If anyone wants to make horizontal scroller which is in between a page template, then we can use this scroller.
    This will help anyone to make a scroller in between a page without disturbing the other element in the page.
    In this we can add as many images as we want, the width of the scroller will take it automatically using jquery.
    HTML:

            <div class="image-gallery">
                <ul class="image-list">
                    <li class="big-image">
                        <a href=""><img src="images/8067fb1cb9a711e385e9128e2849c1ef&#95;8.jpg" alt=""/></a>
                    </li>
    
                    <div class="image-wrapper">
                        <li class="image-top">
                            <a href=""><img src="images/2a2dfa1ab61611e397e912139cd1d695&#95;8.jpg" alt=""></a>
                        </li>
                        <li class="image-bottom">
                            <a href=""><img src="images/0d7827eeafbb11e399e212fd90a3f13f&#95;8.jpg" alt=""></a>
                        </li>
                    </div>
    
                    <li class="big-image">
                        <a href=""><img src="images/3af7eddaa54811e385ff1234c61f9f0f&#95;8.jpg" alt=""></a>
                    </li>
    
                    <div class="image-wrapper">
                        <li class="image-top">
                            <a href=""><img src="images/e0a94bc6a33a11e3a16a122b8b9af17f&#95;8.jpg" alt=""></a>
                        </li>
                        <li class="image-bottom">
                            <a href=""><img src="images/e0a94bc6a33a11e3a16a122b8b9af17f&#95;8.jpg" alt=""></a>
                        </li>
                    </div>
    
                    <li class="big-image">
                        <a href=""><img src="images/ebfe22e29ffe11e3bd500e5958617a65&#95;8.jpg" alt=""></a>
                    </li>
    
                    <div class="image-wrapper">
                        <li class="image-top">
                            <a href=""><img src="images/844398e69f0c11e38c000e4efbc22637&#95;8.jpg" alt=""></a>
                        </li>
                        <li class="image-bottom">
                            <a href=""><img src="images/d1d9aa8a975211e39a0512fb41973d49&#95;8.jpg" alt=""></a>
                        </li>
                    </div>
                </ul>
            </div>
    
    
    CSS:
    
    .clr{
        clear: both;
    }
    
    .image-gallery{
        width:100%
    }
    
    .image-gallery li{
        list-style: none;
        float: left;
        display: inline-block;
    }
    
    .image-gallery li.big-image img{
        width: 400px;
    }
    
    .image-gallery .image-wrapper img{
        width:197px;
    }
    
    .image-wrapper{
        display: inline-block;
        float: left;
        margin: 0 0.5em;
        width: 200px;
       }
    
     ul.image-list{
          padding: 0.5em 0;
          display: block;
    }
    
      ul li.image-top{
          margin-bottom: 3px;
      }
    
     ul li.image-bottom{
          margin-top: 3px;
      }
    
    JS:
    $(document).ready(function(){
        var list&#95;count=0;
        var div&#95;count=0;
        var list&#95;width=0;
        var div&#95;width=0;
        $('.image-list > li').each(function(){
            list&#95;width = $(this).width()+10;
            list&#95;count++;
        })
        $('.image-list > div').each(function(){
            div&#95;width = $(this).width()+10;
            div&#95;count++;
        })
    
        var total&#95;width = (list&#95;count * list&#95;width) + (div&#95;count * div&#95;width);
        console.log(total&#95;width);
        $('.image-list').css({"width":total&#95;width})
    })
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: