banner 3D 结果自适应

《banner 3D 结果自适应》
http://xingeedu.com/

页面

<div id="navbar">
            <div id="box">
                <c:forEach items="${data.value.ads.data }" var="ads" varStatus="vt">
                    <figure class="slide">
                        <a href="${ads.bizParams}" data-img="${ads.image }"></a>
                    </figure>
                </c:forEach>
            </div>
            <div id="time-indicator"></div>
            <nav class="slider-controls">
                <ul id="controls">
                <c:forEach items="${data.value.ads.data }" var="ads" varStatus="vt">
                        <li><a class="goto-slide <c:if test="${vt.index==0 }">current</c:if>" href="#" data-slideindex="${vt.index }"></a></li>
                        </c:forEach>
                </ul>
            </nav>
        </div>

css

#navbar{
    position:relative;
    height:500px;
    overflow:hidden;
    background: url(../../../image/r_loading.gif) #eee no-repeat;
    background-position:center center;    
    background-size:80px 80px;
}
#navbar .slide a{
    background-position:center center;
    display:inline-block;
    width:100%;
    height:500px;
    background-repeat:no-repeat
}            

js

function initBanner(){
        //背景上传宽高为1920*500
        var barImg = $("#navbar").find("a");
        barImg.each(function(){
            var imgURL = $(this).data("img");
            $(this).css({"background-image":"url("+imgURL+")"});
        })
        //轮播
        var $box = $('#box'), $indicators = $('.goto-slide'), $effects = $('.effect'), $timeIndicator = $('#time-indicator'), slideInterval = 5000;
        var switchIndicator = function($c, $n, currIndex, nextIndex) {
            $timeIndicator.stop().css('width', 0);
            $indicators.removeClass('current').eq(nextIndex).addClass(
                    'current');
        };
        //计时条
        var startTimeIndicator = function() {
            $timeIndicator.animate({
                width : '100%'
            }, slideInterval);
        };
        //点点    
        $('#controls').on('click', '.goto-slide', function(ev) {
            $box.boxSlider('showSlide', $(this).data('slideindex'));
            ev.preventDefault();
        });
        
        startTimeIndicator();
        
        $box.boxSlider({
               speed : 1000,
               autoScroll : true,
               timeout : slideInterval,
               next : '#next',
               prev : '#prev',
               pause : '#pause',
               effect : 'fade',
               blindCount : 15,
               onbefore : switchIndicator,
               onafter : startTimeIndicator
           });
        /兼容ie
        if (window.navigator.userAgent.indexOf('Trident') != -1) {
            //兼容
            $box.boxSlider('option', 'effect', "scrollHorz");
        }else{
            //极速形式
            $box.boxSlider('option', 'effect', "scrollHorz3d");
        }
    }    

插件

本文采用了插件:
http://www.html5tricks.com/demo/Adaptors/index.html
    原文作者:dada86
    原文地址: https://segmentfault.com/a/1190000013472399
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞