I'm using the Flickity CSS library to create a horizontal scrolling navigation bar. I've customized the carousel template so that when a cell is selected, it snaps to the center of the bar. The carousel has 5 cells named 'slide 1', 'slide 2', and so on. My challenge now is figuring out how to show the corresponding content only when its carousel cell is selected – otherwise, the content should be hidden.
<nav>
<div class="carousel" data-flickity>
<div class="carousel-cell">
<a href="#slide1">
slide 1
</a>
</div>
<div class="carousel-cell">
<a href="#slide2">
slide 2
</a>
</div>
<div class="carousel-cell">
<a href="#slide3">
slide 3
</a>
</div>
<div class="carousel-cell">
<a href="#slide4">
slide 4
</a>
</div>
<div class="carousel-cell">
<a href="#slide5">
slide 5
</a>
</div>
</div>
</nav>
<!--Content-->
<main>
<div class="container">
<div id="slide1">
SLIDE 1
</div>
<div id="slide2">
SLIDE 2
</div>
<div id="slide3">
SLIDE 3
</div>
<div id="slide4">
SLIDE 4
</div>
<div id="slide5">
SLIDE 5
</div>
</div>
</main>
If you'd like to see my Codepen in action: https://codepen.io/loudenw/pen/jGaxzG