I'm currently working on a web project that utilizes CSS Flexbox. I am trying to create a layout with a fixed left sidebar and a scrollable right side. I have added overflow-y: auto
to the right side content to enable scrolling, but unfortunately, it's not working as expected.
In the CSS, I have used overflow-y: hidden
for the body and overflow-y: auto
for the right side content.
@import url('https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@300&display=swap');
body {
font-family: 'Nunito Sans', sans-serif;
overflow-y: hidden;
}
* {
margin: 0;
padding: 0;
border: 0;
outline: 0;
}
.outside {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
flex-basis: auto;
}
.sidebar {
flex: 1;
list-style: none;
text-decoration: none;
left: 0;
width: 20%;
height: 100vh;
background-color: #666666;
}
.sidebar header {
font-size: 1.7rem;
color: white;
text-align: center;
line-height: 5rem;
background-color: #777777;
user-select: none;
}
.sidebar ul a {
height: 100%;
width: 100%;
line-height: 4rem;
font-size: 1.2rem;
color: white;
padding-left: 2rem;
text-decoration: none;
box-sizing: border-box;
border-bottom: 1px solid rgb(255, 255, 255, .2);
}
ul li:hover a {
font-weight: bold;
}
.products {
flex: 1;
display: flex;
flex-wrap: wrap;
flex-basis: auto;
overflow-y: auto;
overflow-x: auto;
}
.product-card {
display: flex;
min-width: 6rem;
flex-direction: column;
overflow-y: auto;
padding: 2%;
flex: 1 16%;
background-color: #FFF;
box-shadow: 0px 0px 1px 0px rgba(0, 0, 0, 0.25);
}
.product-image img {
width: 100%;
}
.product-info {
margin-top: auto;
padding-top: 20px;
text-align: center;
}
h5 {
font-weight: 500;
line-height: 1.7em;
}
h6 {
color: #666;
font-size: 14px;
}
<div class="outside">
<div class="sidebar">
<header>Apalog</header>
<ul class="sidebar">
<li><a href="#">Dashboard</a></li>
<li><a href="#">My Catalog</a></li>
<li><a href="#">Full Catalog</a></li>
</ul>
</div>
<div class="products">
...
Add product cards here as needed
...
</div>
</div>
I would appreciate any assistance in resolving this issue. Thank you.