I am currently working on a project that requires a responsive layout, and I need the .status
container to display a scrollbar if the content exceeds the available space. The challenge is that I cannot set a fixed height for the .status container as it must remain flexible and responsive. I'm hoping to find a solution using primarily HTML and CSS, but I am also open to incorporating JavaScript, TypeScript, or Angular if necessary.
In this particular case, each .status container should show a scrollbar when the content overflows beyond the available height. However, I am unsure of how to achieve this without specifying a fixed height.
Is there a way to ensure that the .status
container handles overflow correctly in this scenario?
Below is the code snippet I am working with:
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
<style>
* {
box-sizing: border-box;
}
html,
body {
margin: 0;
width: 100%;
height: 100%;
background-color: red;
color: #fff;
text-align: center;
}
.container {
padding: 20px;
width: 100%;
height: 100%;
display: grid;
grid-auto-rows: auto 1fr;
row-gap: 20px;
}
.content-1 {
width: 100%;
height: 60px;
background-color: yellow;
}
.content-2 {
width: 100%;
height: 100%;
background-color: pink;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
gap: 20px;
}
.status {
height: 100%;
max-height: 100%;
background-color: blue;
padding: 5px;
overflow-y: auto;
}
.card {
width: 100%;
height: 200px;
background-color: green;
margin-bottom: 10px;
}
</style>
</head>
<body>
<div class="container">
<div class="content-1"></div>
<div class="content-2">
<div class="status">
<div>Status</div>
<div class="card"></div>
<div class="card"></div>
<div class="card"></div>
<div class="card"></div>
<div class="card"></div>
<div class="card"></div>
</div>
<div class="status">
<div>Status</div>
</div>
<div class="status">
<div>Status</div>
</div>
<div class="status">
<div>Status</div>
</div>
</div>
</div>
</body>
</html>