1

ポートフォリオ ギャラリーのスクロール可能を実装しています。

(scrollable = http://flowplayer.org/tools/index.htmlのスクロール可能なプラグイン)

一度に表示される項目は 1 つです。

デフォルトでは、スクロール可能は前/次ボタンを画像領域の外に配置し、現在の画像をクリックするとスクロール可能なコンテンツが進みます。

  1. 画像領域内で前/次のレンダリングを行いたいと思います。
  2. 画像の下部にマウスを合わせると、画像のキャプションが表示されるようにしたいと考えています。

モックアップ: http://i303.photobucket.com/albums/nn160/upstagephoto/mockups/scrollable_mockup.jpg

これらのいずれかまたは両方を達成する方法についてのアイデアはありますか?

ありがとうございました!

4

2 に答える 2

0

デモ: http://jsbin.com/ijede/2 ソース: http://jsbin.com/ijede/2/edit

$(function() {
    // 5 minute slide show ;-)
    $('.next,.prev').click(function(e) {
        e.preventDefault();
        var pos = parseInt($('.current').attr('id').split('_')[1]);
        var tot = $('.slides a').size() - 1;
        var click = this.className;
        var new_pos = (click == 'next') ? pos + 1: pos - 1;
        var slide = ( click == 'next') ? 
                    (pos < tot ? true : false) : (pos > 0 ? true : false);

        if (slide) $('.current').toggle(500,function() {
          $(this).removeClass('current');
        });
        $('#pos_' + new_pos).toggle(500,function() {
            $(this).attr('class', 'current');
        });
    });
    //cross-browser div :hover
    $('.next,.prev').hover(function() {
      $(this).children().children().fadeIn(500);
    },function() {
      $(this).children().children().fadeOut(500);
    });
    //auto add unique id to each image
    $('.slides a').each(function(e) {
        $(this).attr('id', 'pos_' + e);
        if (!e) $(this).attr('class', 'current');
    });
});​

ソースのCSS !

注:プラグインのドキュメントを読むには、スライドショーを最初から作成するよりも時間がかかるため、新しいスライドショーを作成しました!

あなたがそれを好き願っています!

于 2010-05-10T18:33:18.543 に答える
0

アプローチの主要部分は、html では次のようになります。

<div id="mainContainer">
  <div class="scrollable">
    <div class="items">
      <div class="scrollableEl">
         <img src="yourimage.jpg" />
         <div class="caption">Your caption</div>
      </div>

      <div class="scrollableEl">
         <img src="yourimage2.jpg" />
         <div class="caption">Your caption 2</div>
      </div>

      ... so on ...
    </div>
  </div>
  <a href="#" class="prev">&laquo;</a>
  <a href="#" class="prev">&laquo;</a>
</div>

CSS で次のようにします。

.scrollable {
    position:relative;
    overflow:hidden;
    width: 660px;
    height:90px;
}

.scrollable .items {
    width:20000em;
    position:absolute;
}

.items .scrollableEl {
    float:left;
    positon: relative;
}

.items .scrollableEl .caption {
    display:none;
    position: absolute;
    bottom: 0;
    height: 100px;
    width: 660px;
}

.items .scrollableEl:hover .caption { /*this will show your caption on mouse over */
    display:none;
}

.next, .prev {
    position: absolute;
    top: 0;
    display: block;
    width: 30px;
    height: 100%;
}
.next {
    right: 0;
}
.prev {
    left: 0;
}
#mainContainer {
    position: relative;
}

JavaScript はかなり標準的なはずです。お役に立てれば!

于 2010-05-06T23:09:37.007 に答える