最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Utilise Flexslider caption outslide of Flexslider - Stack Overflow

programmeradmin2浏览0评论

Due to a layout issue I am trying to utilise the .flex-caption outside of the flexslider itself.

Can you think of a way I can achieve this?

Ideally the markup would be structured like this:

<div class="flexslider gallery">
<ul class="slides">
<li><img src="image.jpg"  /></li>
</ul>
</div>

<p class="flex-caption">Caption</p>

Due to a layout issue I am trying to utilise the .flex-caption outside of the flexslider itself.

Can you think of a way I can achieve this?

Ideally the markup would be structured like this:

<div class="flexslider gallery">
<ul class="slides">
<li><img src="image.jpg"  /></li>
</ul>
</div>

<p class="flex-caption">Caption</p>
Share Improve this question asked Aug 31, 2012 at 23:12 Niall ThompsonNiall Thompson 3651 gold badge4 silver badges13 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 6

This solved it without the need for an additional slider:

$captions = $('.captions');

$('.flexslider').flexslider({
    animation: "fade",
    controlNav: true,
    directionNav: false,
    slideshow: false,
    prevText: "Previous",
    nextText: "Next",
    useCSS: true,
    touch: true,
    start: function() {
        $activecaption = $('.flex-active-slide .flex-caption');
        $captions.html($activecaption.text());        
    },
    after: function() {
        $activecaption = $('.flex-active-slide .flex-caption');
        $captions.html($activecaption.text());
    }
});

See example here. ​

Just had the same issue and found a link that helped me solve the issue. Also this is assuming you are looking for the caption to change with the slider navigation.

https://github./woothemes/FlexSlider/issues/108

Basically it involves creating two separate flexsliders and linking them together with navigation controls using this option on the caption slider:

start: function(slider){

            $('.flex-direction-nav li a').click(function(event){
              event.preventDefault();
              var dir = $(this).text().toLowerCase();
              slider.flexAnimate(slider.getTarget(dir));
            });
        }

FYI though, the functionality doesn't seem to work on mobile. Looking into that further.

This solution worked well for me. Thanks! You can also do this with an image caption, instead of text.

after: function() {
   $activecaption = $('.flex-active-slide .flex-caption img');
   $activecaption.clone().prependTo($captions);
}

you want to copy the element, first, then prepend it.

发布评论

评论列表(0)

  1. 暂无评论