My webpage layout is structured as follows:
https://i.sstatic.net/5rdiw.png
The left side, identified as D
, functions perfectly. It contains a significant amount of content that scrolls correctly. Even as the content increases, the height stays at 100% of the webpage's height, allowing for seamless scrolling.
On the right side, there is content in B
. This also works fine. Utilizing Bootstrap 4, B
and A
are set as row
within a col
, each occupying 50% of the parent container.
The issue arises when I want A
to fill the remaining space while being independently scrollable, regardless of the number of C
elements inside it. This means that with one C
, it should take up half the page's height (as shown in the image), and with 20 C
elements, it should maintain the same height, enabling users to scroll to view the 20th C
.
Currently, I can enable vertical scrolling on A
by setting a fixed height like height=350px
, but this is not ideal as desktops have varying screen heights. On the other hand, if I don't specify a height, A
's height adjusts to accommodate all elements inside it, causing the right background layout to exceed the left part of the webpage with just 4 C
elements, disrupting the overall layout.
<div class="right-bg">
<div class="container col" style="height:100%">
<div class="row"> <!-- THIS IS B -->
<div class="col">
<div class="row" id="chart-div">
<canvas id="myChart"></canvas>
</div>
<div class="row horizontal-menu-wrapper">
</div>
</div>
</div>
<div class="container row ranking-container"> <!-- THIS IS A -->
<div class="container rounded-card"> <!-- THIS IS C -->
<div class="row">
<div class="col-lg-1 col-md-1 col-sm-1">
<div id="ranking-trophy-header" class="row card-header">
<i title="General" class="fas fa-trophy header-icon"></i>
</div>
</div>
<div class="col-lg-11 col-md-11 col-sm-11">
<div class="row row-card">
<div class="col-lg-5 col-md-5 col-sm-5">
<p class="ranking-percentage-value"> Top 1%</p>
</div>
<div class="col ranking-field">
<p class="form-field">Position</p>
<p class="form-ranking-value"><span class="absolute-ranking">#<span class="absolute-ranking-value">83</span></span></p>
</div>
<div class="col ranking-field">
<p class="form-field">Pool</p>
<p class="form-pool-value">9470</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
CSS:
html {
height: 100%;
}
body {
height: 100%;
}
.left-bg {
flex-flow: column;
display: flex;
width: 54%;
height: 100%;
overflow: scroll;
padding-bottom: 10px;
}
.right-bg {
flex-flow: column;
display: flex;
width: 46%;
height: 100%;
padding-top: 12px;
}
.ranking-container {
vertical-align: center;
margin: 5px;
margin-top: 15px;
margin-bottom: 5px;
padding: 15px;
overflow: scroll;
border-radius: 10px;
margin-bottom: -9999px;
padding-bottom: 9999px;
}