I am facing a design challenge where I have a main card (1) that contains two sub-cards (2 and 3) using Bootstrap columns. Sub-card number 2 adjusts its height dynamically based on the screen size, while sub-card number 3 consists of a code snippet element and buttons. My goal is to make both sub-cards equal in height. The code snippet element will receive new data dynamically, so I need it to have scroll bars for readability purposes. I managed to achieve this by assigning a specific height to the card:
height: 10rem; overflow: auto; display: flex; flex-direction: column-reverse;
However, I want the height to adapt according to the size of sub-card 1, similar to when the height is set to 100%. So, I want it to look like it does with 100% height but function as if it has a specific height set. Is this feasible?
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css" rel="stylesheet" />
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<div class="mt-1" id="comcard">
<div class="card">
<div class="card-header" id="headingOne">
<button class="btn" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
<i class="fas fa-exchange-alt"></i> CARD
</button>
</div>
<div id="collapseOne" class="collapse hide" aria-labelledby="headingOne" data-parent="#comcard">
<div class="card-body">
<div class="row">
<div class="col-sm col-md-5 col-lg-4 col-xl-3">
<div class="card h-100">
<div class="card-header">
CARD 2
</div>
<div class="card-body">
<form>
<div class="form-group row">
<label for="Select1" class="col-sm-5 col-form-label"> ABCDEFGHIJKL: </label>
<div class="col-sm-7">
<select class="form-control" id="Select1">
<option selected value="0">1</option>
<option value="1">2</option>
</select>
</div>
</div>
</form>
<!-- More form elements here -->
</div>
</div>
</div>
<div class="col-sm col-md-7 col-lg-8 col-xl-9">
<div class="card h-100">
<div class="card-header"> CARD 3 </div>
<div class="card-body d-flex flex-column">
<div class="card" style="height: 100%; overflow: auto; display: flex; flex-direction: column-reverse;">
<div class="card-body" id="terminal_div">
<pre id="terminal_pre"></pre>
</div>
</div>
<fieldset id="group_io">
<div class="input-group mt-2">
<select class="custom-select col-sm-2" id="io_select">
<option value="0" selected>1</option>
<option value="1">2</option>
</select>
<input type="text" class="form-control">
<div class="input-group-append">
<button class="btn btn-outline-success" type="button">Send</button>
</div>
<button type="button" class="btn btn-secondary ml-2">Clear</button>
</div>
</fieldset>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Pre tag with 100% height (Expands indefinitely with new data):
https://jsfiddle.net/Fperola/kL17ewpv/17/
Pre tag with specific height (e.g., 10rem) (Adds scroll bars but not responsive to different screens):