Exploring a web layout where the .cart-items-container
needs to occupy the remaining space above the .cart-rest-details
section. The .cart-items-container
should be scrollable if it overflows while the .cart-rest-details
remains fixed at the bottom of the viewport. However, facing challenges with the layout specifically on mobile devices.
Providing my codebase below:
.cart-container {
display: flex;
flex-direction: column;
gap: 16px;
width: 100%;
height: 100vh;
}
.cart-items-container {
display: flex;
flex-direction: column;
}
.cart-items {
padding: 8px;
max-height: 300px;
overflow: auto;
background-color: #EEEEEE;
border: 2px solid orange
}
.cart-rest-details {
display: flex;
flex-direction: column;
gap: 4px;
width: 90%;
padding: 5%;
background-color: dodgerblue;
color: white;
}
@media screen and (max-width: 768px) {
.cart-items-container {
flex-grow: 1;
}
.cart-items {
flex-grow: 1;
max-height: none;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div class="cart-container">
<div class="cart-items-container">
<h1>Cart Items</h1>
<div class="cart-items">
<p>Item 1</p>
<p>Item 2</p>
<p>Item 3</p>
...
<p>Item 25</p>
</div>
</div>
<div class="cart-rest-details">
<p>Description 1</p>
<p>Description 2</p>
<p>Description 3</p>
...
</div>
</div>
</body>
</html>
Experiencing issues on mobile devices where the .cart-items-container
doesn't fill the remaining space correctly and the scrolling behavior in the .cart-items
isn't as expected.
Current Behavior:
https://i.sstatic.net/1KKAshY3.png
Expected Behavior: