javascript - Utilise Flexslider caption outslide of Flexslider - Stack Overflow

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

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744852303a4597197.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信