Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Carousel - associate text with images in slider

I am using Owl Carousel for a simple carousel on my website. I'd like to have a different piece of text displaying over each image.

As you can see, I can click the dots and they change which one is active, but I'd like to create a little jQuery to change the quote text & author when I do this.

Demo: http://jsfiddle.net/fq77rd1d/

HTML:

<div class="hero-form lazy">
    <div class="hero-carousel / owl-carousel js-hero-carousel">
        <div class="hero-carousel__item owl-lazy" style="background:url('https://placeholdit.imgix.net/~text?txtsize=47&txt=500%C3%97500&w=500&h=500') 0 0 no-repeat"></div>
    <div class="hero-carousel__item owl-lazy" style="background:url('https://placeholdit.imgix.net/~text?txtsize=47&txt=500%C3%97500&w=500&h=500') 0 0 no-repeat"></div>
    </div>
    <div class="hero-form__inner container">
        <div class="container">
            <div class="row">
                <div class="col-md-6 pull-md-6">
                    <div class="hero-form__footer">
                        <div class="hero-form__quote">
                            <blockquote>
                                <p>&ldquo;Quote 1&rdquo;</p><span class="cite">Author</span>
                            </blockquote>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="hero-carousel-nav owl-nav">
        <div class="owl-prev"><svg><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#slider-arrow-left"></use></svg></div>
        <div class="owl-next"><svg><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#slider-arrow-right"></use></svg></div>
    </div><span class="hero-overlay"></span>
</div>

JavaScript:

$(document).ready(function () {
    $(".owl-carousel").owlCarousel({

        autoPlay: 3000, //Set AutoPlay to 3 seconds
        dots: true,
        items: 2,
        itemsDesktop: [1199, 3],
        itemsDesktopSmall: [979, 3]
    });
});
like image 921
michaelmcgurk Avatar asked Dec 07 '25 11:12

michaelmcgurk


1 Answers

It looks like the contents of your <svg>s (#slider-arrow-left and #slider-arrow-right) are not loading. Are they defined anywhere in your CSS, because you don't seem to load it...

To check:

.owl-prev > svg, .owl-next > svg { background: red; }

To fix, use some proper path|text|... in your <svg>s.

like image 177
tao Avatar answered Dec 10 '25 00:12

tao



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!