What is the best way to ensure that a div takes up as much vertical space as possible within its

Check out my design at https://jsfiddle.net/49hsztuh/

Take a look at the code snippet below:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<style>
@charset "utf-8";
html,body {
    height:100%;
    width:100%;
}

.chatContainer {
    font-family:Nunito; 
    font-size:0.9em;
    background-color:red;
    height:800px;
}
.chatHeader {
    height:50px;
    background-color:#363b3f;
    color:white;
    padding-left:10px;
}

#myWebcamDiv {
    height:260px;
    width:100%;
    background-color:black;
    padding:0px;
}

#chatUsers {
    margin-top:10px;
    overflow-y:scroll;
    overflow-x:hidden;
    width:100%;
    height:320px;
    background-color:blue;
}
#chatCams {
    width:100%;
    background-color:#FeFeFe;
    padding:0px;
    display:inline-block;
    overflow-y:hidden;
    overflow-x:auto;
    white-space: nowrap;

}
.chatText {
    height:250px;
    padding:10px;
    background-color:yellow;
    color:black;
    overflow-x:none;
    overflow-y:scroll;
}

</style>

</head>

<div class="col-md-12 chatContainer">

    <div class="chatHeader"></div>
    <div class="col-md-4" id="chatLeftColumn" >
        <div id="myWebcamDiv"></div>        

        <div id="chatUsers"></div>        
    </div>

    <div class="col-md-8" id="chatRightColumn">
        <div id="chatCams"></div>       
        <div role="tabpanel">

          <!-- Nav tabs -->
          <ul id="pageTab" class="nav nav-tabs" role="tablist">

          <li class="active">
          <a  href="#LoungeRoom" role="tab" data-toggle="tab">LoungeRoom</a></li></ul>

          <!-- Tab panes -->
          <div id="pageTabContent" class="tab-content">
            <div role="tabpanel" class="tab-pane active chatText" id="LoungeRoom"></div>
            <div class="tab-pane chatText" id="LoungeRoom"></div>
          </div>

        </div>    


        <div id="chatInputDiv"></div>            

    </div>

</div>

I'm looking to extend the blue and yellow sections all the way down to the bottom of the red container. (make sure you view the fiddle with a min width).

Any suggestions on how to achieve this?

Answer №1

To ensure that the children flow properly within their parent container, it is important to set their height equal to that of the parent. This will prevent them from overflowing beyond the boundaries of the parent element. If the children's height starts below the top of their parent, they may extend past the bottom of the parent.

#chatUsers {
    margin-top:10px;
    overflow-y:scroll;
    overflow-x:hidden;
    width:100%;
    height:800px; /* height of parent */
    background-color:blue;
}

.chatText {
    height:800px; /* height of parent */
    padding:10px;
    background-color:yellow;
    color:black;
    overflow-x:none;
    overflow-y:scroll;  
}

To handle overflowing children, apply the overflow:hidden property to the parent container.

.chatContainer {
    font-family:Nunito; 
    font-size:0.9em;
    background-color:red;
    height:800px;
    overflow: hidden; /* hide overflow */
}

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

Styling the jQuery location picker input with background and focus effects

While working on a web app using jQuery locationpicker, I noticed that it's causing some styling issues with the input. Despite being able to adjust properties like width, padding, and border, changing the background requires using jQuery. Here is th ...

Why is it that the default theme of Material UI lacks any stylization at all?

After experimenting with both Carbon Design for React (@carbon/react) and Material UI (@mui/material) in conjunction with Next.js, I encountered styling issues with the components. While they functioned correctly to some extent, there were noticeable discr ...

What is the best way to ensure that all the divs within a grid maintain equal size even as the grid layout changes?

I have a grid of divs with dimensions of 960x960 pixels, each block is usually 56px x 56px in size. I want to adjust the size of the divs based on the changing number of rows and columns in the grid. Below is the jQuery code that I am using to dynamicall ...

Tips for switching the irregular polygon shape image on click and hoverIf you want to change

I'm looking to create a unique menu with an irregular shape in Adobe Illustrator. I've attempted the following code: <div class="body_container"> <img src="img/sitio_Web.png" alt="" usemap="#sitio_Web_Map" height="787" bor ...

Don't forget to strip off the height attribute once the transform is

Utilizing the transform property: .parent { display: inline-flex; flex-direction: column; align-items: center; } .first { height: 100px; } .second { height: 100px; transform: translateY(-50%); } <div class="parent"> <div ...

Tips for effectively showcasing div elements

https://jsfiddle.net/qz8hL574/1/ for (var key in table) { if (table.hasOwnProperty(key)) { $('<div class="element"></div>').appendTo('#list'); document.getElementsByClassName("element")[key].innerHTML = ...

Achieving Centered Items with CSS Flexbox and Positioning

Struggling to arrange 3 elements using flexbox while keeping them centered both horizontally and vertically. Here is the desired layout: https://i.sstatic.net/Uo6WS.png This is my current attempt, but it's not working as expected. Can anyone spot t ...

Hamburger must be used in order for the menu to be displayed

Whenever I visit the site, the menu remains hidden. However, when I resize the page and use the hamburger icon, the menu appears as expected. Even after resizing the page back to its original size, the menu continues to be visible. Refreshing the sit ...

When hovering over an anchor, apply a border or box-shadow effect to the image

I'm trying to make an image display a border or box-shadow when hovering over a link, along with an animated circle around the round image. I've attempted to achieve this with the following CSS code, but it doesn't seem to be working. https ...

Utilizing Bootstrap to arrange table cells in a shifted manner

I'm new to utilizing bootstrap in web development. I've been exploring various examples of bootstrap templates that include tables, and I noticed that when I resize my browser window, the table adjusts accordingly. Now, I'm curious to know ...

Magento theme installation on the website encountered unexpected obstacles

Hi everyone, I'm currently in the process of constructing a website with Magento. However, I've encountered some issues after trying to install a theme. It seems like certain files, including CSS, are not loading properly. To provide better conte ...

Add formatting to specific list items within the Ui Fabric Nav element

https://i.sstatic.net/BcCbj.png Please take a look at the provided screenshot. In the list, some items are marked with an eye icon to indicate that they are hidden and not important for the user's immediate attention. However, this icon seems to have ...

What steps can I take to ensure these three images all have identical height and width?

Just starting out with Bootstrap 4 and I have a question about making images inside a card the same height and width. Can anyone help me figure out which div to input an attribute to achieve this? Here's the HTML code below the image: <link href ...

Having trouble with the float not working for the main content below the sidebar? Stay tuned

Here is the layout I am working with: .page-wrapper { height: 100%; min-height: 970px; position: relative; } .pageheader { min-height: 50px; position: fixed; min-width: 100%; } .navbar-fixed-top { top: 0; } .page-sidebar { float: left ...

Changing the font family for Bootstrap Glyphicons on a button

I have recently started using Bootstraps Glyphicons and encountered an issue while trying to insert text inside a button with a glyphicon icon: <button type="button" class="btn btn-default pull-left" data-toggle="collapse" data-bind="attr:{'href&a ...

Troubleshooting Problem with Responsive Bootstrap Navbar

I've been working on creating a menubar using Bootstrap where the logo image is centered instead of being on the left side of the bar. However, I'm facing an issue where the right links in the menu go off the screen. When I view the page with a w ...

The text for the Google chart is nowhere to be found

After creating a test project using the Google Chart example, I noticed that some text from the chart is missing after adding CSS. Here is the CSS code I used: html, body { font-size: 100%; height: 100%; width: 100%; } body { background: ...

Customize dropdown item colors in React using a color picker

I am currently utilizing a react color picker to create a personalized 16 color gradient. The process involves selecting a color from a dropdown menu and then using the color picker to make adjustments. This action updates an array that dictates the stylin ...

Using jQuery to Retrieve Check Box Labels and Populate Them into Textboxes

I would like to display the name of the selected checkbox label in a textbox. If multiple checkboxes are selected, I want their labels to be separated by commas and displayed in the textbox. Please excuse my poor English. $(document).ready(function() { ...

The sidebar remains fixed in height and does not expand vertically

Need Help: My sidebar won't expand in height when I update content. Is there a way to make it adjust using just HTML and CSS? html code: <div id="main"> <section> More text goes here... </section> <div id="sideb ...