I have a page with a side navigation bar and content on the right.
Inside the content, I have a carousel with images that I want to horizontally scroll on overflow.
Below is an example:
body {
height: 100%;
}
.container {
display: flex;
height: 100%
}
nav {
border: 1px solid black;
}
article {
border: 1px solid black;
width: 100%;
display: flex;
}
.content {
overflow: hidden;
}
.carousel {
flex-wrap: nowrap;
display: flex;
overflow: auto;
width: auto;
}
.box {
width: 200px;
height: 200px;
border: 1px solid red;
display: inline-block;
flex-shrink: 0;
}
<div class="container">
<nav>
<ul>
<li>This</li>
<li>is</li>
<li>the</li>
<li>side</li>
<li>navigation</li>
<li>bar</li>
</ul>
</nav>
<article>
<div class="content">
This is the main content
<div class="carousel">
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
<div class="box">4</div>
<div class="box">5</div>
<div class="box">6</div>
<div class="box">7</div>
<div class="box">8</div>
<div class="box">9</div>
<div class="box">10</div>
</div>
</div>
</article>
</div>
As you can see, it horizontally scrolls, but it goes beyond the right edge of the page. How can I fix this so that only the carousel scrolls horizontally, but the whole page doesn't scroll?