我目前正在使用我的主页上的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> 提前谢谢。
发布于 2012-03-16 15:36:46
使用<img />中的title属性定义要在滑块中显示为标题的文本。
让我们看一个例子:
<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>更新
在不修改代码的情况下,您可以重写默认类,使其显示为单独的文本框。
找到.nivo-caption样式并对其进行一些更改
.nivo-caption {
width: 200px;
height: 250px;
left: -200px; /* same as the width */
}更新2
这是一个带有滑块的demo,可以使用我提到的变通方法。
就这个问题而言,这就是我要说的。希望能有所帮助。
发布于 2012-08-29 09:21:05
<div id="slider" class="nivoSlider">
<div class="slide slide_0">
<img class="slide-image" src='img1.png' width="100%" title="#htmlcaption_0">
</div>
<div class="slide slide_1">
<img class="slide-image" src='img2.png' width="100%" title="#htmlcaption_1">
</div>
<div class="slide slide_2">
<img class="slide-image" src='img3.png' width="100%" title="#htmlcaption_2">
</div>
</div>
<div id="htmlcaption_0" class="nivo-html-caption">
<h1 class="slide-h1">Title</h1>
<h2 class="slide-h2">Description</h2>
<h3 class="slide-h3">
<a href="#" title="">Learn More »</a>
</h3>
</div>
<div id="htmlcaption_1" class="nivo-html-caption">
<h1 class="slide-h1">Title</h1>
<h2 class="slide-h2">Description</h2>
<h3 class="slide-h3">
<a href="#" title="">Learn More »</a>
</h3>
</div>
<div id="htmlcaption_2" class="nivo-html-caption">
<h1 class="slide-h1">Title</h1>
<h2 class="slide-h2">Description</h2>
<h3 class="slide-h3">
<a href="#" title="">Learn More »</a>
</h3>
</div>这是我的css:
.nivo-caption {
color: #FFFFFF;
min-width: 550px;
overflow: hidden;
position: absolute;
top: 180px;
z-index: 8;
}
.nivo-html-caption {
display:none;
}希望这能有所帮助。
发布于 2012-03-16 15:41:39
https://stackoverflow.com/questions/9733527
复制相似问题