The child divs are not adjusting to the height of the parent container

My goal is to have the height of the children div .cell fill up 100% of the parent's height, but it doesn't seem to be working.

This is the HTML code:

<div class="header">
    header
</div>
<div class="wrapper">    
    <div class="padding">
        <div class="table bg">
            <div class="cell">
                hello world
            </div>
            <div class="cell">
                dummy text
            </div>
        </div>
    </div>
</div>
<div class="footer">
    footer
</div>

Here is the CSS code:

html,body{height:100%;}
body{margin:0;padding:0;}
.footer,.header{background:black;height:30px;color:white;}
.wrapper{min-height:calc(100% - 60px);height:auto !important;}
.padding{padding:20px;}
.table{display:table;width:100%;}
.cell{display:table-cell;}
.bg{background:#ccc;}

I suspect that the issue lies with this part of the CSS:

.wrapper{min-height:calc(100% - 60px);height:auto !important;}

When I change .wrapper to this:

.wrapper{height:calc(100% - 60px);}

It seems to work as intended.

You can view the fiddle here.

Answer №1

Offspring components do not automatically acquire the min-height attribute from their parents.

Therefore, modify min-height:calc(100% - 30px); ...

to height:calc(100% - 30px); on your container and then specify height:100% on child divs to inherit that particular height.

FIDDLE

FIDDLE2 (lots of content)

.wrapper
{
  height:calc(100% - 60px); /* <--- */
}
.padding
{
  padding:20px;
  height: 100% /* <--- */
  -moz-box-sizing: border-box;
  box-sizing: border-box; /* <--- */
}
.table
{
  display:table;
  width:100%;
  height: 100%; /* <--- */
}

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

Challenges encountered while using Selenium WebDriver to upload images

I'm having trouble adding an image as a normal attachment to an email (not as an inline image). When inspecting the HTML DOM with Firebug, I noticed there are two elements with xpath //input@type='file', which is due to the presence of two b ...

Retrieving Table Characteristics from an Online Source

Currently utilizing Python 3.4, Windows 10, and Visual Studio 2015 for my project. I am in the process of developing a program that scrapes phone numbers from websites similar to this one. My approach involves using Beautiful Soup 4 to extract the number ...

adjusting the space between lines for paragraphs with exceptionally large text

Utilizing Bootstrap allows for the adjustment of paragraph font sizes to appear quite large, mimicking the size and style of a heading without the need for an actual heading level HTML tag. I am hesitant to use a genuine <H2> tag to alter the visual ...

How can a borderless text field be created using Material UI?

Today, I delved into using Material UI for my React project. My goal is to create a registration form similar to this one. Essentially, I want 5 input text fields without any borders and with a simple background color effect when active. However, I'm ...

Class Background Imagery

Currently leveraging Wpbakery for my website design. Seeking to apply the FadeInUp animation solely to the background image rather than the entire row. Any suggestions on accomplishing this? Is there a method to assign a class solely to the background i ...

Combining dropdowns, nav-pills, and separate links in Bootstrap 4 to create a seamless horizontal layout

Trying to achieve a layout in Firefox where everything is displayed in one single horizontal row. This includes the label Dropdown, dropdown box itself, bootstrap nav-pills menu, and separate link. Code snippet: (jsfiddle: https://jsfiddle.net/aq9Laaew/16 ...

I could use some help navigating payment gateways

I'm new to payment gateways and would appreciate any recommendations or advice. ...

What is the best way to ensure DIVs or SPANs have a fixed width with their content while also utilizing the remaining available space with white space?

My current setup is similar to the following. <div width="100%"> <span width="33%">FIRSTNAME</span> <span width="33%">|LASTNAME</span> <span width="33%">|CITY</span> </div> When executed, it appears a ...

Executing Controller method from an HTML webpage

I have designed a webpage in Html called SomePage.Html, and I am looking to trigger a method every time someone visits this page. Let's say I have a Controller named DefaultController with a method called - Get() and I want this method to be executed ...

Guidelines for placing an HTML element in relation to another HTML element using CSS or JavaScript

Is there a way to position an HTML element in relation to another using CSS or JavaScript? I have attempted to copy the inner HTML of the "second-element" and append it inside the "first-element", but this approach is causing issues with other functional ...

The input focus placeholder at the top is not functioning properly when applied to an input field that

I recently designed an input box similar to this: https://i.stack.imgur.com/lkSnh.png However, I encountered an issue when trying to make the input box readonly. Here is a snippet of my code: .myinput input:focus { outline: none; } ... <div clas ...

html body extends beyond the negative position of the element

If you visit my website at this link, try resizing the window until the responsive design kicks in. Then, click on the "right" button at the top of the page. You'll notice that the right sidebar disappears and reappears, but when it disappears, the ba ...

Utilizing interpolation for a CSS class defined in an external file within Angular 2

Is it feasible to send a variable to a CSS class in an external CSS file within Angular 2, such as: import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', sty ...

The colors of my SVG button remain constant and do not dynamically change when I hover over it

I am facing an issue with a button that contains an SVG element. In my CSS, I have defined styles to change the color of the icon and the SVG when hovered over. However, I noticed that I have to directly hover over the SVG itself for the color to fill. As ...

Tips on customizing default Polymer CSS

Currently, the core-toolbar features an indent class that shifts the title to the right by 60px. However, material design guidelines suggest that the margin should actually be 80px (oddly enough, the number 60 is not mentioned in the documentation). I cou ...

What is the best way to conceal a div element on a Razor Page depending on the user's input?

How can I display the state field only when the user selects United States in the country field, and hide it otherwise? Here is the code snippet from my cshtml page: <div class="form-group col-sm-4 mt-4"> <label asp-for="Form.Co ...

Focusing on a specific image using Jquery

I am looking to specifically target the image within the "hero1project3" class, however, the image is currently set as a background. Is there a way in jQuery to apply effects like blur only to the image itself, for example, using ".hero1project3 img"? HTM ...

How to find and pair up custom data attributes that are unfamiliar?

Is there a method to select elements with unspecified custom data attributes? When I say unspecified, I am referring to an element that could appear like this: <div data-unknown="foo"></div> or <td data-someOtherCustomDataAttribute="bar"& ...

How can I place a DOM element without relying on style properties?

Before diving in, let me provide some context. I am currently developing a visual element that operates similar to a spreadsheet. It features scrollable content areas in both directions, with axis indicators on the left and top that remain visible at all t ...

The Analog Clock is unable to access the property of null

I'm struggling to understand what's wrong here. The querySelector doesn't seem to be functioning correctly as I keep encountering the error "cannot read the property of null" on line 10 of my JavaScript code. const deg = 6; const hr = docum ...