mercredi 25 février 2015

Bootstrap collapse when clicking on images

I'm creating a website for a music festival (a small one). Like you can see in this example : http://ift.tt/1wlPOFv (This is only a test website). I would like to have collapse div when I click on image, witch show the information about the artist. when I click on an other image, I would like to hide the active div then show the other corresponding to the image click.


Before asking on stackoverflow, I'd already tried some code related to bootstrap collapse. Like you can see in "Samedi soir" section when I click on the image, it work but if I click on the second one, the div related to the first image doesn't close. I think Javascript is needed but I do not understand anything about it.


I'd like some advise about what I want to do. Is the collapse function the best solution in this case, or maybe another solution is better?


My code :



<section id="saturday-night">
<div class="full-container">
<div class="row">
<h2>Samedi Soir</h2>
<div class="panel-group" id="accordion">
<div class="grid">

<div class="panel panel-default">

<figure class="effect-lily">
<img src="images/artistes/12.jpg" alt="img12"/>
<figcaption>
<div>
<h2>First <span>Image</span></h2>
<p>Lily likes to play with crayons and pencils</p>
</div>
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#panel1">Panel 1</a>
</figcaption>
</figure>
</div>

<div class="panel panel-default">

<figure class="effect-lily">
<img src="images/artistes/12.jpg" alt="img12"/>
<figcaption>
<div>
<h2>Second <span>image</span></h2>
<p>Lily likes to play with crayons and pencils</p>
</div>
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#panel2">Panel 1</a>
</figcaption>
</figure>
</div>

<div id="panel1" class="panel-collapse collapse">
<div class="panel-body">
<p>Contents panel 1</p>
</div>
</div>

<div id="panel2" class="panel-collapse collapse">
<div class="panel-body">
Contents panel 2
</div>
</div>
</div>
</div>


...


Aucun commentaire:

Enregistrer un commentaire