Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add a links to pictures in Twitter Bootstrap Carousel?

I want to make the pictures that scroll through the carousel. Also, when we click on them, they open the Hyperlink.

like image 417
jofishing Avatar asked Aug 20 '13 15:08

jofishing


1 Answers

Simply, envelope images with href tag. So, if we modify the example of the official documentation:

<div id="myCarousel" class="carousel slide">
    <ol class="carousel-indicators">
        <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
        <li data-target="#myCarousel" data-slide-to="1"></li>
        <li data-target="#myCarousel" data-slide-to="2"></li>
    </ol>
    <div class="carousel-inner">
        <div class="item active">
            <a href="http://estiloasertivo.blogspot.com.es/"> 
                <img src="http://lh5.ggpht.com/-tNlXRzR4qMw/ThaowBgad2I/AAAAAAAAD6I/OEd6kbouBvk/s1600-h/chapi%25255B4%25255D.png" alt="">

                <div class="carousel-caption">
                    <h4>First Thumbnail label</h4>
                    <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam.
                        Donec id elit non mi porta gravida at eget metus. Nullam id dolor
                        id nibh ultricies vehicula ut id elit.</p>
                </div>
            </a>
        </div>
        <div class="item">
            <a href="http://www.youtube.com/watch?v=Ehv0iriLTKE"> 
                <img src="http://www.chistosos.com.mx/wp-content/uploads/2012/07/perro-gracioso-en-coche-aire-chistosa.jpg" alt="">

                <div class="carousel-caption">
                    <h4>Second Thumbnail label</h4>
                    <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam.
                        Donec id elit non mi porta gravida at eget metus. Nullam id dolor
                        id nibh ultricies vehicula ut id elit.</p>
                </div>
            </a>
        </div>
        <div class="item">
            <a href="http://www.google.cn/">
                <img src="http://www.theandrewblog.net/wp-content/uploads/2012/04/ant.jpg"  alt="">

                <div class="carousel-caption">
                    <h4>Third Thumbnail label</h4>
                    <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam.
                        Donec id elit non mi porta gravida at eget metus. Nullam id dolor
                        id nibh ultricies vehicula ut id elit.</p>
                </div>
            </a>
        </div>
    </div>
    <a class="left carousel-control" href="#myCarousel" data-slide="prev">&lsaquo;</a>
    <a class="right carousel-control" href="#myCarousel" data-slide="next">&rsaquo;</a>
</div>
like image 63
chelder Avatar answered Oct 21 '22 13:10

chelder