Populate the content of the child DIV to match the grid layout as a whole

I am attempting to control the layout of the grid on my website using CSS. By utilizing Bootstrap 4, I have created two divs with equal height using display:grid. However, I am facing difficulties in managing the child elements within these divs. I am trying to create a contenteditable div and use JavaScript to display server-side information to the user. My challenge lies in making the height of the div adjust dynamically based on its parent content without hard-coding a fixed height.

<div class="row">   
    <div class="col-xl-8 col-lg-12 col-md-12 col-sm-12 col-12" style="display: grid;">
        <div class="card shadow mb-4">          
            <div class="card-header py-3">
                <h6 class="card-title m-0 font-weight-bold text-primary">
                    param
                </h6>
            </div>              
            <div class="card-body">             
                <div class="row mb-2">                  
                    <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
                        <textarea rows="13" maxlength="1500"></textarea>
                    </div>                      
                </div>                  
            </div>
        </div>
    </div>      
    <div class="col-xl-4 col-lg-12 col-md-12 col-sm-12 col-12" style="display: grid;">
        <div class="card shadow mb-4">
            <div class="card-header py-3">
                <h6 class="card-title m-0 font-weight-bold text-primary">
                    consol
                </h6>
            </div>
            <div class="card-body">
                <div class="row mb-2">                  
                    <div id='console' class='mb-2'
                        style="min-height: 150px; border-radius: 5px; resize: none; width: 100%; height: 100%; border: 0px; background-color: #f8f8f8; padding: 2px 2px;"
                        name="console" contenteditable="false"></div>
                </div>                  
            </div>              
        </div>
    </div>
</div>

To enhance comprehension and visualization, I have included an image.

Answer №1

Attempt to adjust the height of the second card-body row to 100%; You can utilize Bootstrap's class "h-100".

            <div class="card-body">
            <div class="row mb-2" style="height:100%">                  
                <div id='console' class='mb-2'
                    style="min-height: 150px; border-radius: 5px; resize: none; width: 100%; height: 100%; border: 0px; background-color: #f8f8f8; padding: 2px 2px;"
                    name="console" contenteditable="false"></div>
            </div>                  
        </div>

Answer №2

If you want to make the div fill the parent height, simply use the BS-class h-100. Make sure to also verify if the row-div has a height of 100%.

<div class="col-xl-4 col-lg-12 col-md-12 col-sm-12 col-12" style="display: grid;">
            <div class="card shadow mb-4">
                <div class="card-header py-3">
                    <h6 class="card-title m-0 font-weight-bold text-primary">
                        consol
                    </h6>
                </div>
                <div class="card-body">
                    <div class="row h-100 mb-2">                  
                        <div id='console' class='h-100 mb-2'
                            style="min-height: 150px; border-radius: 5px; resize: none; width: 100%; border: 0px; background-color: #f8f8f8; padding: 2px 2px;"
                            name="console" contenteditable="false"></div>
                    </div>                  
                </div>              
            </div>
        </div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Associate information with HTML elements

I've come across this question multiple times, but the solutions are mostly focused on HTML5. My DOCTYPE declaration is: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> I'm looking t ...

Limit access to Google Fusion Table to specific types of maps. Eliminate Google Fusion Table for selected map formats

Currently, I am in the process of creating a web map using the Google Maps Javascript API. My objective is to display a Google Fusion Table containing buildings in Boston exclusively on a stylized map named "Buildings." When I switch to the Buildings map t ...

Connecting with a php anchor and hash symbol in a website URL

Looking to include a PHP anchor along with a hash anchor in an HTML link. <?php echo '<a href="test.php?page='.$i.'#hash">'.$i.'</a>'; ?> The PHP code successfully echoes the link, but upon clicking it, th ...

Steps for importing selenium web elements:

Can all of these ... tags be extracted simultaneously? I aim to retrieve every ... from that particular webpage! Web address: 'https://school.programmers.co.kr/learn/challenges?order=recent&page=1' ...

Is it possible to delete an element from both local storage and HTML by referencing its ID?

Experience a simple flashcard game where you enter a question and answer to create a new flash card stored as an object within the cards array. The newly created flash card is also displayed by appending a new element to the flash cards section on the webp ...

Robotic Arm in Motion

GOAL: The aim of the code below is to create a robotic arm that consists of three layers (upper, lower, and middle), all connected to the base. There are four sliders provided to independently move each part except for the base which moves the entire arm. ...

Setting the background color of a table header to 70% width within a table is achievable

I'm looking to style the th attribute with a bgcolor, but only at a width of 70%. The header reads "Mega Event Offer" and I want to give it a background color as well. However, since its width is large, it's overlapping onto the heading. Is there ...

Adjusting the width of the rail in Material UI's vertical Slider component in React

After attempting to adjust the width and height of the rail property on the material ui slider I obtained from their website demo, I have encountered an issue with changing the thickness. import React from "react"; import { withStyles, makeStyles } from " ...

Pictures glide within containers

Hey, I'm having an issue with my images. They're not floating like they should be, even though they are centered in the div. I really want them to float and be centered. Here's the code snippet I've been working with. HTML <div cla ...

Are there any instances where CSS is overlooking certain HTML elements?

In the following HTML code snippet, the presence of the element with class ChildBar is optional: <div class="Parent"> <div class="ChildFoo"></div> <div class="ChildBar"></div> <!-- May ...

SQL query for finding the number of shared nodes between two given nodes

How can we determine the common nodes between two specific nodes in SQL, using the following example: Count the occurrences of <li> tags between <h2 id="vgn">VGN A </h2> and <h2 id="vgn">VGN </h2>, as well as the total number ...

The Viadeo Social Toolbox seems to be encountering technical difficulties at the moment

I attempted to utilize a Viadeo Social Toolbox, specifically the Viadeo Share Button, but it seems to be malfunctioning in certain browsers? I came across some outdated viadeo share URLs like this: http://www.viadeo.com/shareit/share/?url=${url}&title ...

"Combining multiple DIVs into a single DIV with jQuery - a step-by-step guide

I have multiple DIVs with the same class, and I am looking to group them into a single DIV using either jQuery or pure JS. <div class="a"> <div>1</div> </div> <div class="a"> <div>2</div> ...

Displaying JavaScript array contents in an HTML page without using the .innerHTML property

As someone new to the world of JavaScript and web development, I find myself faced with a challenge. I want to showcase the contents of two different JavaScript arrays in an HTML format. However, my research has led me to believe that utilizing .innerHTML ...

Provide spacing on the sides for a background position

Is there a way to evenly space my background image with 10px margins on all sides instead of just the left side? Currently, it's only working on the left side. .login-page { display: flex; flex-direction: column; background: url("../src/As ...

What methods can I use to identify my current page location and update it on my navigation bar accordingly?

My latest project involves a fixed sidebar navigation with 3 divs designed to resemble dots, each corresponding to a different section of my webpage. These sections are set to occupy the full height of the viewport. Now, I'm facing the challenge of de ...

What is the best way to utilize jQuery for deleting the final <li> within a <ul> element?

One of my web pages contains an unorganized list similar to this: <ul id="myList"> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> <li>Item 4</li> </ul> How can I target the last ...

Adjust the font size of MaterialUI icons using CSS

I am currently facing an issue where I need to increase the size of my icons by 200px, but they are defaulting to 24px which is the standard for all Google Icons. Any suggestions on how to solve this? HTML <div class="col span-1-of-4 box"> <i ...

Adding text on top of an image

I am having trouble with the master slider plugin as slide1, 2, and 3 each have unique classes. I attempted to overlay text on the image but it is not showing up. I tried using the following CSS code but nothing appeared on the screen. .classnameslide1: ...

Enhance the numerical value displayed in jQuery UI tooltips

I have folders with tooltips displaying text like '0 entries' or '5 entries' and so on. I am looking for a way to dynamically update this tooltip number every time an item is added to the folder. The initial count may not always start a ...