Flex: Maximize the use of the remaining surface area by filling it with a panel

I am having trouble filling the remaining surface of my page until the footer with a panel using the style panel-grow-shrink. Any suggestions on how to make it work?

.flex-column-container {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    justify-content: flex-start;
    align-content: stretch;
    align-items: stretch;
}

.panel-grow-shrink {
    order: 0;
    flex: 1 1 auto;
    align-self: stretch;
background-color:red;
}

.btn-toolbar {
    /*margin-left: -5px;*/
}
.panel-body {
    padding: 15px;
}
body{
    background-color:yellow;
}
<div class="flex-column-container">
    <div>
        <h1><span>Title</span></h1>
    </div>
    <div class="panel-body">
        <div class="panel-grow-shrink">
Panel fills the remaining area
        </div>
        <div class="btn-toolbar">
            <button type="button" >Button1</button>
            <button type="button" >Button2</button>
            <button type="button" >Button3</button>
            <button type="button" >Button4</button>
        </div>
    </div>
</div>

I am looking to add a footer at the bottom of the page, and I want the panel with the class panel-grow-shrink to expand to fill the height of the remaining surface. However, in this example, the footer is not positioned at the bottom as intended.

Answer №1

By setting the flex-column-container to display flex, you are ensuring that the div containing the title and the div with the "panel-body" class will be displayed in a flexible manner. However, the elements within the "panel-body" such as "panel-grow-shrink" and "btn-toolbar" will not follow this flex behavior unless specifically defined. I have included a code snippet below for clarification.

.flex-column-container{
  display:flex;
  flex-direction:column;
  background-color:blue;
  min-height:350px;
}

.title{
}

.panel-body {
    display: flex;
    flex-direction: column;
    background-color:pink;
    flex-grow:1; /*expands to fill remaining space*/
}

.panel-grow-shrink {
   flex-grow:1;/*expands to fill remaining space*/
background-color:red;
}

.btn-toolbar {
    /*margin-left: -5px;*/
}
.panel-body {
    /*padding: 15px;*/
}
<div class="flex-column-container">
    <div class="title">
        <h1><span>Title</span></h1>
    </div>
    <div class="panel-body">
        <div class="panel-grow-shrink">
Panel to fill the rest of the region
        </div>
        <div class="btn-toolbar">
            <button type="button" >Button1</button>
            <button type="button" >Button2</button>
            <button type="button" >Button3</button>
            <button type="button" >Button4</button>
        </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

Transferring checkbox data to Bootstrap modals and dynamically summoning specific div modals using their unique identifiers

I have been trying to populate the checkbox values into corresponding modal divs based on button clicks, but I am facing difficulties in achieving it. Desired outcome: The buttons should trigger the display of selected checkbox values in their respective ...

Older versions of Firefox are unable to detect a link that has been registered by the Vue event handler

Here is the HTML code that I am working with: <button id="btncontinue" ref="btncontinue" v-on:click="oncontinueclick" v-show="continuevisible"> <i class="fa fa-arrow-alt-circle-right fa-2x continue-icon" v-show="continuevisible"></i> &l ...

Guide on using PHP to assign the value of an array to an input field

Here is an array I have: $texts = [ "maybank2u.com", "Open BillPayment", "Status: Successful", "Reference number 2950211545", "Transaction date: 01 Feb 2016 13:09:17", "Amount: RM100.00", ...

changing CSS styles

I'm struggling with what seems like a simple issue and can't find a solution anywhere. The HTML element I have is <div class="box"> It originally has this rule in its stylesheet: .box { width: 40%; } My Custom CSS sheet overwrites the o ...

Experience a seamless integration of playing videos in the background using HTML5 with responsive design

Looking for a CSS trick to create a video background that spans the full width of the browser and auto resizes with the browser size. It's essential that it plays on Safari, so please specify the supported video file types. ...

What is the correct way to utilize the submit() function within this specific form?

I have a small registration form that requires validation before submission. In order to achieve this, I've developed a JavaScript function as shown below: var name = document.getElementById('name').value; var company = document.getElem ...

When the mouse is moved, display a rectangle on the canvas

I am having an issue with drawing a rectangle on canvas. The code below works fine, except that the path of the rectangle is not visible while the mouse is moving. It only appears when I release the mouse button. Any assistance would be greatly appreciate ...

What strategies can be utilized to enhance the cleanliness of these functions?

Is there a way to avoid adding new lines of JS code every time I add a new image to the HTML? $(document).ready(function() { $('.btn').click(function() { var bid = $(this).attr('id'); if(bid=="img1" || bid == "img2" || bid == "img3"){ ...

Develop various Checkboxes using JavaScript

I am attempting to dynamically create multiple checkboxes using JavaScript. I have written the following code: var response= data; var container = document.createElement('div'); var checkboxContainer = document.createElement(&apo ...

Do we actually need the role attributes "radiogroup" and "radio"?

Some ARIA tutorial websites use non-semantic markup and javascript to demonstrate the use of role="radiogroup" and role="radio", as shown in the example below: <ul role="radiogroup"> <li tabindex="-1" role="radio" aria-checked="false"> ...

What is the best way to retrieve a value from a form and incorporate it into a controller?

Here is the code I've been working on: http://pastebin.com/AyFjjLbW I started learning AngularJS and was making progress, but now I'm facing a challenge. I'm trying to use a drop-down menu to select both a priority level and a type of job t ...

Incorporating CSS and JavaScript into a Spring application

I have been searching on stackoverflow for a solution to my problem, but I am still struggling to make it work despite following the suggested steps. What I want to achieve is to include static files (css, js, img) in my project and access them using HTML ...

Guide to adding text descriptions for synchronized media as outlined in WCAG 2.0 Success Criterion 1.2.2

Based on the guidelines of WCAG 2.0 success criterion 1.2.2: 1.2.2 Captions (Prerecorded) Level A Captions are provided for all prerecorded audio content in synchronized media, except when the media is a media alternative for text and is clearly labeled ...

Use Bootstrap 4.3.1 to seamlessly weave text around a video on your website

I've been grappling with this, but I just can't seem to crack it. <div class="container-fluid"> <div class="row"> <div class="col-lg-4 order-1 mb-auto mt-auto"> & ...

Submitting PHP query to SQLite database using a button trigger

In my webpage, I am working with HTML and PHP to create a form. Within this form, there are two checkboxes: one populates its options from a table in the database related to products, while the other is a multi-select checkbox that gets populated from a di ...

Is there a method in AngularJS to submit form data when the input fields are pre-populated using a GET request?

How do I submit form data in AngularJS? I have a div that populates the input field from a GET request. Now, I want to send this data using a POST method. How can I achieve this? Below is the form div: <div class="row" ng-app="myApp" ng-controller="myC ...

What is preventing Google Chrome from automatically breaking?

I seem to have made a mistake in this document, but I can't quite pinpoint what it is. There isn't much content in here yet as I am still in the process of building it for a WB. Interestingly, it works in Internet Explorer but not in Google Chrom ...

The content of the DIV element is not displaying properly when trying to list items

I have a div that is styled with the following CSS properties : HTML <div class="messageContainer"></div> CSS .messageContainer { margin-left: 2px; background-color: #F7F5F2; width: 100%; min-height: 50px; border: solid 1px silver ...

Can content be transferred from one div to another using only CSS?

CSS <style> #layer1 { height: 60px; background-color:#00FF00; } #layer2 { height: 60px; background-color:#FFFFCC; } </style> HTML <div id="layer1"> This is the first div. </div> <div id="layer2"> This i ...

Using Angular to dynamically display JSON data on an HTML page

I have JSON data that I need to format into an HTML page where each parent becomes the header and its children are displayed under the same parent in the content area. Another parent will follow with its respective children listed below. How can I achiev ...