nivo滑块 - 向滑块添加文本

oli*_*rbj 5 html jquery slider

我目前正在我的主页上使用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 -->
Run Code Online (Sandbox Code Playgroud)

正如您在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> 
Run Code Online (Sandbox Code Playgroud)

提前致谢.

Sta*_*arx 16

使用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>
Run Code Online (Sandbox Code Playgroud)

更新

在不破解代码的情况下,您可以覆盖默认类以显示为单独的文本框.

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

.nivo-caption { 
       width: 200px; 
       height: 250px; 
       left: -200px; /* same as the width */
 }
Run Code Online (Sandbox Code Playgroud)

更新2

这是一个演示,您的滑块使用我提到的解决方法.

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