jQuery Cycle 寻呼机功能使用现有的缩略图进行导航

发布于 2024-11-04 08:02:01 字数 2819 浏览 0 评论 0原文

我正在为我妻子的照明设计业务开发一个作品集网站。 jQuery 循环插件似乎提供了我想要的功能,但即使在查看了 Mike Alsup 网站上的示例之后,我还是感到困惑。真的,我只是没有 JavaScript 背景来完成这个任务。

我想构建一个幻灯片,由寻呼机功能控制,使用缩略图进行导航。主幻灯片和缩略图的宽高比完全不同(以保持布局),因此我无法使用循环为我生成缩略图。幻灯片包括图像和标题。我想保留尽可能多的现有标记。

以下是幻灯片内容:

<div id="slideshow" />
        <div class="first">
            <img src="../_/img/projects/shootingstar-1.jpg" alt="" />
            <p class="credit">caption here</p>
        </div>
        <div>
            <img src="../_/img/projects/shootingstar-2.jpg" alt="" />
            <p class="credit">caption here</p>
        </div>
        <div>
            <img src="../_/img/projects/shootingstar-3.jpg" alt="" />
            <p class="credit">caption here</p>
        </div>
        <div>
            <img src="../_/img/projects/shootingstar-4.jpg" alt="" />
            <p class="credit">caption here</p>
        </div>
        <div>
            <img src="../_/img/projects/shootingstar-5.jpg" alt="" />
            <p class="credit">caption here</p>
        </div>

这是缩略图/导航内容。我尝试对图像使用一致的命名约定:

<div id="slidenav">
        <li><a href="#"><img src="../_/img/projects/shootingstar-1t.jpg" alt="" /></a></li>
        <li><a href="#"><img src="../_/img/projects/shootingstar-2t.jpg" alt="" /></a></li>
        <li><a href="#"><img src="../_/img/projects/shootingstar-3t.jpg" alt="" /></a></li>
        <li><a href="#"><img src="../_/img/projects/shootingstar-4t.jpg" alt="" /></a></li>
        <li><a href="#"><img src="../_/img/projects/shootingstar-5t.jpg" alt="" /></a></li>
    </div>

最后,我的样式,以防在某种程度上有帮助:

#slidenav {display: block; float: right; width: 200px;}
#slidenav li {list-style: none; float: left;}
#slidenav li img {padding: 2px; border: 1px solid #999; margin: 0 0 8px 8px;}
#projectcopy {display: block; float: right; width: 220px;}
#projectcopy p {font-size: 12px; color: #666; line-height: 16px; margin: 0 10px 20px 16px; text-align: right;}
#projectcopy ul {list-style: none; margin: 0 10px 20px 16px;}
 #projectcopy ul li {font-size: 11px; color: #666; line-height: 14px;  text-align: right; margin-bottom: 10px;}

我在这里发布了一个示例:

http://pritchardlighting.com/nova/portfolio/sample-project.html

您可以看到我目前只在幻灯片上设置了一个简单的循环。请忽略混乱。显然,这仍处于开发阶段。

我真的很感激任何帮助。这一定是其他人尝试过做的事情。我只是很难理解到目前为止所看到的示例。他们都假设(正确地)对 JS 有基本的了解,而我只是不具备。

I'm working on a portfolio site for my wife's lighting design business. The jQuery cycle plugin seems to provide the functionality I want, but even after reviewing the examples on Mike Alsup's site, I'm stumped. Really, I just don't have the background with JavaScript to pull this off myself.

I want to build a slideshow, controlled with a pager function, using thumbnails for navigation. The main slides and the thumbnails are totally different aspect ratios (to maintain the layout), so I can't use cycle to generate the thumbnails for me. The slides include an image and a caption. I'd like to preserve as much of the existing markup as possible.

Here is the slideshow content:

<div id="slideshow" />
        <div class="first">
            <img src="../_/img/projects/shootingstar-1.jpg" alt="" />
            <p class="credit">caption here</p>
        </div>
        <div>
            <img src="../_/img/projects/shootingstar-2.jpg" alt="" />
            <p class="credit">caption here</p>
        </div>
        <div>
            <img src="../_/img/projects/shootingstar-3.jpg" alt="" />
            <p class="credit">caption here</p>
        </div>
        <div>
            <img src="../_/img/projects/shootingstar-4.jpg" alt="" />
            <p class="credit">caption here</p>
        </div>
        <div>
            <img src="../_/img/projects/shootingstar-5.jpg" alt="" />
            <p class="credit">caption here</p>
        </div>

Here is the thumbnail/navigation content. I tried to use a consistent naming convention for the images:

<div id="slidenav">
        <li><a href="#"><img src="../_/img/projects/shootingstar-1t.jpg" alt="" /></a></li>
        <li><a href="#"><img src="../_/img/projects/shootingstar-2t.jpg" alt="" /></a></li>
        <li><a href="#"><img src="../_/img/projects/shootingstar-3t.jpg" alt="" /></a></li>
        <li><a href="#"><img src="../_/img/projects/shootingstar-4t.jpg" alt="" /></a></li>
        <li><a href="#"><img src="../_/img/projects/shootingstar-5t.jpg" alt="" /></a></li>
    </div>

And finally, my styling, in case that is helpful in some way:

#slidenav {display: block; float: right; width: 200px;}
#slidenav li {list-style: none; float: left;}
#slidenav li img {padding: 2px; border: 1px solid #999; margin: 0 0 8px 8px;}
#projectcopy {display: block; float: right; width: 220px;}
#projectcopy p {font-size: 12px; color: #666; line-height: 16px; margin: 0 10px 20px 16px; text-align: right;}
#projectcopy ul {list-style: none; margin: 0 10px 20px 16px;}
 #projectcopy ul li {font-size: 11px; color: #666; line-height: 14px;  text-align: right; margin-bottom: 10px;}

I have an example posted here:

http://pritchardlighting.com/nova/portfolio/sample-project.html

You can see that I currently just have a simple cycle set up on the slides. Please ignore the mess. Obviously, this is still in dev.

I would really appreciate any help. This has to be something that others have tried to do. I'm just having a hard time making my way through the examples I've seen so far. They all assume (rightly so) a baseline understanding of JS that I just don't possess.

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

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

发布评论

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

评论(2

战皆罪 2024-11-11 08:02:03

请参阅此演示来回答您的问题:

please refer to this demo to have your question answered:

滥情哥ㄟ 2024-11-11 08:02:03
  1. 删除围绕要循环的内容的所有 div(div#slideshow 的子元素。它们会阻止循环工作,因为脚本会循环 ONE div 中的所有内容)。
  2. 出于同样的原因删除 p.credit 。否则脚本会循环执行,如果没有匹配的缩略图(请参阅 3),您就会遇到麻烦。
  3. 请确保缩略图 {*t.jpg} 的数量与 {div#slideshow} 中的 img 数量精确匹配。这就是让它发挥作用的一点。不匹配会导致脚本无法工作。
  4. 完全使用演示中的 jquery 标记,

如果仍然无法正常工作,请将 {pager: '#nav',} 替换为 {pager: '#slidenav',},如果脚本加载,请使用 firebug 检查。如果是,请先尝试使循环 {div#slideshow} 运行,然后再前进到链接的缩略图。

  1. remove all divs you have wrapped around your content to cycle (the child elements of div#slideshow. they prevent cycle from working as the script cycles everything within ONE div).
  2. remove p.credit for the same reason. otherwise the script cycles it and you run into trouble if you have no matching thumbnail (see 3.)
  3. make sure, the number of thumbnails {*t.jpg} matches precisely the number of img in {div#slideshow}. thats the point that makes it work. mismatch leads to a non working script.
  4. use exactly the jquery markup from the demo and replace {pager: '#nav',} with {pager: '#slidenav',}

if still not working check with firebug if the script loads. if yes, try first to make the cycle {div#slideshow} running before you move forward to the linked thumbnails.

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