使用图像上的上一页和下一页自定义可滚动插件? (参见模拟)

发布于 2024-08-29 14:13:33 字数 590 浏览 10 评论 0原文

我正在为投资组合画廊实现一个可滚动的。

(scrollable = 来自 http://flowplayer.org/tools/index.html 的可滚动插件)

一次只能看到一个项目。

默认情况下,可滚动将上一个/下一个按钮放置在图像区域之外,并且单击当前图像前进可滚动内容。

  1. 我希望在图像区域内显示上一个/下一个渲染。
  2. 我希望当鼠标悬停在图像的下部时出现图像标题。

小样: http://i303.photobucket.com/albums/nn160/upstagephoto/ mockups/scrollable_mockup.jpg

关于如何实现其中一项或两项有什么想法吗?

谢谢你!

I am implementing a scrollable for a portfolio gallery.

(scrollable = scrollable plugin from http://flowplayer.org/tools/index.html )

There will be one item visible at a time.

By default, scrollable positions the prev/next buttons outside of the image area and clicking on the current image advances the scrollable content.

  1. I would like to have the prev/next render within the image area.
  2. I would like to have an image caption appear when mousing over the lower part of the image.

Mock-up:
http://i303.photobucket.com/albums/nn160/upstagephoto/mockups/scrollable_mockup.jpg

Any ideas on how to achieve one or both of these?

Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

树深时见影 2024-09-05 14:13:33

你的方法的主要部分将在你的 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">«</a>
  <a href="#" class="prev">«</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 应该是相当标准的。希望这有帮助!

The main part of your approach will be like this in your 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">«</a>
  <a href="#" class="prev">«</a>
</div>

And like so in your 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;
}

The javascript should be fairly standard. Hope this helps!

我不吻晚风 2024-09-05 14:13:33

演示: 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 来源!

注意:由于阅读插件文档比从头开始制作幻灯片需要更多的时间,所以我制作了一个新的幻灯片!

希望你喜欢它!

DEMO: http://jsbin.com/ijede/2 SOURCE: 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 on source!

NOTE: since read the plugin doc require more time for me than make a slideshow from scratch, i have maked a fresh one!

hope you like it!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文