【发布时间】:2014-05-29 10:14:11
【问题描述】:
我在我的网页上使用 Nivo Slider,我想要做的是让当前幻灯片图像在花式灯箱中弹出。
我当前的 jquery 是。
<script type="text/javascript">
$(window).load(function() {
$('#slider').nivoSlider({
effect: 'slideInLeft', // Specify sets like: 'fold,fade,sliceDown'
slices: 15, // For slice animations
boxCols: 8, // For box animations
boxRows: 4, // For box animations
animSpeed: 500, // Slide transition speed
pauseTime: 3000, // How long each slide will show
startSlide: 0, // Set starting Slide (0 index)
directionNav: true, // Next & Prev navigation
controlNav: true, // 1,2,3... navigation
controlNavThumbs: false, // Use thumbnails for Control Nav
pauseOnHover: true, // Stop animation while hovering
manualAdvance: false, // Force manual transitions
prevText: 'Prev', // Prev directionNav text
nextText: 'Next', // Next directionNav text
randomStart: false, // Start on a random slide
beforeChange: function(){}, // Triggers before a slide transition
afterChange: function(){}, // Triggers after a slide transition
slideshowEnd: function(){}, // Triggers after all slides have been shown
lastSlide: function(){}, // Triggers when last slide is shown
afterLoad: function(){} // Triggers when slider has loaded
});
});
</script>
我的 HTML 是。
<div class="colE">
<div style="height: 265px; margin-top: 25px" id="slider" class="nivoSlider">
<img src="/images/new.jpg" alt=""/>
<img src="/images/new1.jpg"" alt=""/>
<img src="/images/new2.jpg"" alt=""/>
<img src="/images/new3.jpg"" alt=""/>
</div>
</div>
CSS 主要是我添加的标准版本。
<style>
.nivoSlider {
position:relative;
width:100%;
height:auto 265px;
overflow: hidden;
}
.nivoSlider img {
position:absolute;
top:0px;
left:0px;
max-width: none;
display: none;
}
.nivo-main-image {
display: block !important;
position: relative !important;
width: 100% !important;
}
/* If an image is wrapped in a link */
.nivoSlider a.nivo-imageLink {
position:absolute;
top:0px;
left:0px;
width:100%;
height:100%;
border:0;
padding:0;
margin:0;
z-index:6;
display:none;
}
/* The slices and boxes in the Slider */
.nivo-slice {
display:block;
position:absolute;
z-index:5;
height:100%;
top:0;
}
.nivo-box {
display:block;
position:absolute;
z-index:5;
overflow:hidden;
}
.nivo-box img { display:block; }
/* Caption styles */
.nivo-caption {
position:absolute;
left:0px;
bottom:0px;
background:#000;
color:#fff;
width:100%;
z-index:8;
padding: 5px 10px;
opacity: 0.8;
overflow: hidden;
display: none;
-moz-opacity: 0.8;
filter:alpha(opacity=8);
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box; /* Firefox, other Gecko */
box-sizing: border-box; /* Opera/IE 8+ */
}
.nivo-caption p {
padding:5px;
margin:0;
}
.nivo-caption a {
display:inline !important;
}
.nivo-html-caption {
display:none;
}
/* Direction nav styles (e.g. Next & Prev) */
.nivo-directionNav a {
position:absolute;
top:45%;
z-index:9;
cursor:pointer;
}
.nivo-prevNav {
left:0px;
}
.nivo-nextNav {
right:0px;
}
/* Control nav styles (e.g. 1,2,3...) */
.nivo-controlNav {
text-align:center;
padding: 15px 0;
}
.nivo-controlNav a {
cursor:pointer;
}
.nivo-controlNav a.active {
font-weight:bold;
}
.nivoSlider {
position:relative;
background:#fff url(images/loading.gif) no-repeat 50% 50%;
width:65%;
height:100%;
margin-bottom:10px;
}
.nivoSlider img {
position:absolute;
top:0px;
left:0px;
display:none;
}
.nivoSlider a {
border:0;
display:block;
}
.nivo-controlNav {
text-align: center;
padding: 0 0;
margin-left: -300px;
}
.nivo-controlNav a {
display:inline-block;
width:22px;
height:22px;
background:url(images/bullets.png) no-repeat;
text-indent:-9999px;
border:0;
margin: 0 2px;
}
.nivo-controlNav a.active {
background-position:0 -22px;
}
.nivo-directionNav a {
display:block;
width:30px;
height:30px;
background:url(images/arrows.png) no-repeat;
text-indent:-9999px;
border:0;
opacity: 0;
-webkit-transition: all 200ms ease-in-out;
-moz-transition: all 200ms ease-in-out;
-o-transition: all 200ms ease-in-out;
transition: all 200ms ease-in-out;
}
.nivoSlider:hover .nivo-directionNav a { opacity: 1; }
a.nivo-nextNav {
background-position:-30px 0;
right:15px;
}
a.nivo-prevNav {
left:15px;
}
.nivo-caption {
font-family: Helvetica, Arial, sans-serif;
}
.nivo-caption a {
color:#fff;
border-bottom:1px dotted #fff;
}
.nivo-caption a:hover {
color:#fff;
}
.nivo-controlNav.nivo-thumbs-enabled {
width: 100%;
}
.nivo-controlNav.nivo-thumbs-enabled a {
width: auto;
height: auto;
background: none;
margin-bottom: 5px;
}
.nivo-controlNav.nivo-thumbs-enabled img {
display: block;
width: 120px;
height: auto;
}
</style>
更新
这是 JSFiddle,
它似乎不像在网站上那样工作??
它做了它应该做的就是幻灯片我只想在当前幻灯片上添加弹出功能。
我希望代码不多,或者帖子有误,如果有,请告诉我,我会更新它。
谢谢。
【问题讨论】:
-
如果可能,请分享 jsfiddle。
-
您需要将您的图像包装在一个带有href到您的图像src的锚中,然后在您的文档加载调用
$('.nivoSlider a').fancybox();不确定将您的图像包装在锚中是否会破坏您的nivoslider -取决于它是否查找子元素或图像。 -
@Innovation heres jsfiddle.net/6AqR6 似乎不像在网站上那样工作。
标签: javascript jquery fancybox fancybox-2 nivo-slider