bga*_*oci 3 html javascript css jquery jquery-ui
我正在寻找一个JQuery解决方案,如位于http://www.bazaarvoice.com的旋转横幅.
其中有一个定时滚动但也允许用户通过滚动标签进行切换.谁知道一个好的,容易风格的?
使用适用于jQuery 的Cycle Lite插件.它有一个小的足迹和你需要的所有功能:
编辑:这是一个示例代码:
您需要Cycle插件,而不是Cycle Lite插件.
HTML:
<div id="slideshow">
<ul class="pager">
<!-- will be populated with thumbs by JS -->
</ul>
<!-- each div is considered as a slide show -->
<div><img src="/images/banner1.png" />You can place text here too !</div>
<div><img src="/images/banner2.png" /></div>
<div><img src="/images/banner3.png" /></div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
.thumb.selected {
border: 2px gray solid;
}
ul.pager li {
list-style: none;
float: left;
width: 200px;
height: 80px;
background-color: #eee;
}
#slideshow > div {
background-color: #eee;
border: 1px solid #ddd;
}
Run Code Online (Sandbox Code Playgroud)
使用Javascript:
$("#slideshow").cycle({
fx: 'fade', // name of transition effect (or comma separated names, ex: fade,scrollUp,shuffle)
timeout: 1000, // milliseconds between slide transitions (0 to disable auto advance)
speed: 400, // speed of the transition (any valid fx speed value)
pager: "#tabs",// selector for element to use as pager container
pagerClick: null, // callback fn for pager clicks: function(zeroBasedSlideIndex, slideElement)
pagerEvent: 'hover',// name of event which drives the pager navigation
pagerAnchorBuilder: function(i, slide){// callback fn for building anchor links: function(index, DOMelement)
return '<li class="thumb" id="thumb-1"><img src="' + slide.src + '" height="30" width="40" /></a></li>';
},
before: function(){ // deselect all slides
$(".thumb").removeClass('selected');
},
after: function(foo, bar, opts){ // select current slide
$("#thumb-"+opts.currSlide).addClass('selected');
},
fit: 1, // force slides to fit container
pause: 1, // true to enable "pause on hover"
pauseOnPagerHover: 1, // stop slideshow when pagers are being hovered
autostop: 0, // true to end slideshow after X transitions (where X == slide count)
autostopCount: 0, // number of transitions (optionally used with autostop to define X)
slideExpr: "div", // all content of div#slider is a slide. but not the pager
fastOnEvent: 100, // force fast transitions when triggered manually (via pager or prev/next); value == time in ms
});
Run Code Online (Sandbox Code Playgroud)
享受,它是未经测试的,但应该工作.
Edit2:
用pager替换pagerAnchorBuilder选项return '<li class="thumb" id="thumb-1"><img src="' + slide.src + '" /></a></li>';
我想你想改变宽度和/或高度.Juste删除HTML高度,并使用CSS属性:.thumb img { height: 10px; width: 10px; }
您还可以添加一些自定义CSS属性.