利用jQuery实现Adaptor幻灯片代码



50 199 67



特效描述:利用jQuery实现Adaptor幻灯片代码,利用jQuery实现Adaptor幻灯片代码

代码结构

1. 引入CSS

<link href='http://fonts.googleapis.com/css?family=Aldrich' rel='stylesheet'>
<link href="css/screen.css" rel="stylesheet">

2. 引入JS

<script src="js/lib/modernizr.min.js"></script>
<script src="//code.jquery.com/jquery-1.7.2.min.js"></script>
<script>window.jQuery || document.write('<script src="js/lib/jquery-1.7.2.min.js"><\/script>')</script>
<script src="js/box-slider-all.jquery.min.js"></script>

3. HTML代码

	  <div id="page">
      <section>
        <header>
          <hgroup>
            <h1>Adaptor</h1>
            <h2>jQuery content slider</h2>
          </hgroup>
        </header>
        <div id="viewport-shadow">
          <a href="#" id="prev" title="go to the next slide"></a>
          <a href="#" id="next" title="go to the next slide"></a>
          <div id="viewport">
            <div id="box">
              <figure class="slide">
                <img src="img/the-battle.jpg">
              </figure>
              <figure class="slide">
                <img src="img/hiding-the-map.jpg">
              </figure>
              <figure class="slide">
                <img src="img/theres-the-buoy.jpg">
              </figure>
              <figure class="slide">
                <img src="img/finding-the-key.jpg">
              </figure>
              <figure class="slide">
                <img src="img/lets-get-out-of-here.jpg">
              </figure>
            </div>
          </div>
          <div id="time-indicator"></div>
        </div>
        <footer>
          <nav class="slider-controls">
            <ul id="controls">
              <li><a class="goto-slide current" href="#" data-slideindex="0"></a></li>
              <li><a class="goto-slide" href="#" data-slideindex="1"></a></li>
              <li><a class="goto-slide" href="#" data-slideindex="2"></a></li>
              <li><a class="goto-slide" href="#" data-slideindex="3"></a></li>
              <li><a class="goto-slide" href="#" data-slideindex="4"></a></li>
            </ul>
          </nav>
        </footer>
      </section>
      <aside id="effect-switcher">
        <h2>Select effect</h2>
        <ul id="effect-list">
          <li><a href="#" class="effect current" data-fx="scrollVert3d">Vertical 3D scroll</a></li>
          <li><a href="#" class="effect" data-fx="scrollHorz3d">Horizontal 3D scroll</a></li>
          <li><a href="#" class="effect" data-fx="scrollVert">Vertical scroll</a></li>
          <li><a href="#" class="effect" data-fx="scrollHorz">Horizontal scroll</a></li>
          <li><a href="#" class="effect" data-fx="blindLeft">Blind left</a></li>
          <li><a href="#" class="effect" data-fx="blindDown">Blind down</a></li>
          <li><a href="#" class="effect" data-fx="fade">Fade</a></li>
        </ul>
      </aside>
      <footer id="credits">
        <p>from:<a href="http://51qianduan.com" target="_blank">Phil Parsons</a> web:<a href="http://51qianduan.com/" target="_blank">lanrentuku.com</a> thank:<a href="http://51qianduan.com/" target="_blank">Dave Hill</a></p>
        <p>{download}</p>
        <p>{content}</p>
        <p>{google_729x90}</p>
      </footer>
	  </div>
		<script>
		  $(function () {
        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: '680px'}, slideInterval);
        };
        // initialize the plugin with the desired settings
        $box.boxSlider({
            speed: 1000
          , autoScroll: true
          , timeout: slideInterval
          , next: '#next'
          , prev: '#prev'
          , pause: '#pause'
          , effect: 'scrollVert3d'
          , blindCount: 15
          , onbefore: switchIndicator
          , onafter: startTimeIndicator
        });
        startTimeIndicator();
        // pagination isn't built in simply because it's easy to
        // roll your own with the plugin API methods
        $('#controls').on('click', '.goto-slide', function (ev) {
          $box.boxSlider('showSlide', $(this).data('slideindex'));
          ev.preventDefault();
        });
        $('#effect-list').on('click', '.effect', function (ev) {
          var $effect = $(this);
          $box.boxSlider('option', 'effect', $effect.data('fx'));
          $effects.removeClass('current');
          $effect.addClass('current');
          switchIndicator(null, null, 0, 0);
          ev.preventDefault();
        });
		  });
		</script>



用户评论
大牛,别默默的看了,快登录帮我点评一下吧!:)      登录 | 注册


热门标签: 滑动导航菜单 导航切换 图片翻转旋转 图片淡出淡进 滑动选项卡切换 文字翻转旋转 文字淡出淡进 图片滑动 图片切换 旋转木马 文字滑动 文字切换 滑动手风琴 背景切换 滑动星星打分 手风琴 选项卡自动切换 视频切换 列表切换 渐隐切换 全屏切换 切换按钮 缩放切换 滑动滑过 滚动切换 滑动选项卡切换 选项卡切换 滑动手风琴 转动旋转翻转 渐隐切换 淡出淡入淡进

×
×

注册

官方QQ群

扫描上面二维码加微信群

官方QQ群

jQuery/js讨论群
群号:642649996
Css3+Html5讨论群
群号:322131262

加群请备注:从官网了解到