I would like to have a scrollbar for a specific div container. So what I currently have is this
$(document).ready(() => {
for (let i = 0; i < 100; i++) {
const newDiv = (`<div>Log Item</div>`);
$("#logsContainer").append(newDiv);
}
});
#page {
display: grid;
grid-template-columns: 50% 50%;
height: 100%;
}
@media (max-width: 800px) {
#panel {
grid-template-columns: 100%;
grid-template-rows: 50% 50%;
}
}
#logsContainer {
overflow-y: scroll;
height: 100px;
/*
calc(100% - 18px);
18px because the "Logs" title has a height of 18
*/
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="page">
<div>
Commands
</div>
<div>
<div>
Logs
</div>
<div id="logsContainer">
</div>
</div>
</div>
As you can see the logs have their own scrollbar on a hardcoded height of 100px. I would like to stretch this container to the bottom (100%). Of course I have to subtract the title height from it. So if I pass in calc(100% - 18px);
I get this result
$(document).ready(() => {
for (let i = 0; i < 100; i++) {
const newDiv = (`<div>Log Item</div>`);
$("#logsContainer").append(newDiv);
}
});
#page {
display: grid;
grid-template-columns: 50% 50%;
height: 100%;
}
@media (max-width: 800px) {
#panel {
grid-template-columns: 100%;
grid-template-rows: 50% 50%;
}
}
#logsContainer {
overflow-y: scroll;
height: calc(100% - 18px);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="page">
<div>
Commands
</div>
<div>
<div>
Logs
</div>
<div id="logsContainer">
</div>
</div>
</div>
but as you can see the div container has a height greater than 100% of the page height. How do I stretch that log container correctly?