nivo slider - 将文本添加到滑块

2024-04-21

我目前在主页上使用 nivo 滑块来显示不同的图像。它工作完美。不过,图像旁边有一些文字,我想跟随每张图片。

HTML 代码如下:

     <!-- Splash -->
            <div class="splash">
              <div class="splash-content">
<div id="text1">                
<h1>More traffic to your website</h1>
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elitectetur adipis. In ultrices malesuada est eu laoreet. Nullam eget tellus ac lacus bibendum egestas et at libero. Vestibulum commodo magna ut suscipit.</p>
</div>                
              </div>

            <div id="slider" class="nivoSlider nivo-right theme-default">
                <img src="images/splash.png" alt="" title="" />
                <img src="images/splash.png" alt="" title="" />
                <img src="images/splash.png" alt="" title="" />
                <img src="images/splash.png" alt="" title="" />

            </div>


        </div><!-- End Splash -->

正如您在 HTML 代码中看到的,有<div id="slider">,这是 nivo 滑块。虽然,我希望拥有<div id="text1">跟随每张图片。然后有一个<div id="#text2">跟随下一张图片等等。

控制 nivo 滑块的 jQuery 代码:

<script type="text/javascript">
$(window).load(function() {
    $('#slider').nivoSlider({
        effect: 'sliceUp', // Specify sets like: 'fold,fade,sliceDown'
    });
});
</script> 

提前致谢。


Use title属性中的<img />定义在滑块中显示为标题的文本。


让我们看一个例子:

<div id="slider" class="nivoSlider">
    <img src="images/slide1.jpg" alt="" />
    <img src="images/slide2.jpg" alt="" title="#htmlcaption" />
                                             <!-- ^ This is one way to bring caption -->
    <img src="images/slide3.jpg" alt="" title="This is an example of a caption" />
                                             <!-- ^ This is ANOTHER way -->
</div>

<!-- This part of caption is called from the second image link above see  `#htmlcaption` there -->
<div id="htmlcaption" class="nivo-html-caption">
    <strong>This</strong> is an example of a <em>HTML</em> caption with <a href="#">a link</a>.
</div>

Update

无需修改代码,您就可以覆盖默认类以显示为单独的文本框。

Find .nivo-caption样式并对其进行一些更改

.nivo-caption { 
       width: 200px; 
       height: 250px; 
       left: -200px; /* same as the width */
 }

Update 2

这里有一个demo http://jsfiddle.net/Starx/7Myy2/使用您的滑块使用我提到的解决方法。

就这个问题而言,这就是我停下来的地方。希望能帮助到你。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

nivo slider - 将文本添加到滑块 的相关文章