When both the container and the element have min-height specified in percentages, CSS min-height may not be effective

Check out this simple markup:

<div class="fixh">

    <div class="outer">
        <div class="inner">
            inner
        </div>

    </div>

</div>

I am trying to ensure that the inner block has a minimum height of 100% of the outer block, even if the content overflows. Unfortunately, setting min-height:100% on the inner block doesn't seem to work! Here is an example to illustrate the issue: http://jsfiddle.net/mBBJM/5378/

Answer №1

Using percentages with <code>min-height
may not work effectively. To resolve this, it would be best to simply use height:100% instead:

.fixh {
    width: 300px;
    height: 300px;
    background-color: green;
}

.outer {
    width: 100%;
    height: 100%;
    min-height: 100%;
    background-color: blue;
}

.inner {
    width: 100%;
    height: 100%;
    min-height: 100%;
    background-color: gray;
}
<div class="fixh">
    <div class="outer">
        <div class="inner">
            inner
        </div>
    </div>
</div>

It's important to always include height and width styles when using min-height or min-width to ensure proper functionality. Similarly, for max-height and max-width, specifying these styles is crucial for the desired outcome.

Answer №2

I trust this aligns with your inquiry.

http://jsfiddle.net/w9Lghbuw/1/

.fixh {
    width: 300px;
    height: 300px;
    background-color: green;
}
.outer {
    width: 100%;
    min-height: 100%;
    background-color: blue;
    height: 100%;
}
.inner {
    color:#fff;
    width: 100%;
    height: 100%;
    line-height: 20px;
    word-break: break-all;
    overflow: auto;
}

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

Mobile devices with a horizontal scroll

Having trouble with side scrolling on mobile devices. I've set two @media queries for tablet and mobile. Visit dev.bdbshop.com @media only screen and (max-width: 767px) { .wrap { max-width: 300px; } Could the issue be related to this? Any suggestio ...

The loading of the Bootstrap tagsinput has encountered an error

I am facing an issue with my Django application where tags are not loading properly in an input field using jquery. It seems like the application is unable to locate the bootstrap-tagsinput.css and bootstrap-tagsinput.js files. Can anyone provide guidance ...

Navigate to the parent element in the DOM

Looking to add some unique styling to just one of the many Mat dialog components in my project. It seems like modifying the parent element based on the child is trickier than expected, with attempts to access the DOM through the <mat-dialog-container> ...

Can you please provide me with detailed instructions on how to use the radio button?

As someone who isn't a professional coder, I dabble in creating code for fun. Right now, I'm working on a roleplay project on a website where each character has a designated "space" to input HTML and CSS code as a template. I've stumbled upo ...

What is the best way to access a model attribute in every template?

My goal is to showcase the name of my model team in the website header. The Team model has a attribute named "name": class Team(models.Model): name = models.CharField(max_length=50, null=True, blank=True) In my template language, I am trying to disp ...

Can the data cells of columns be dynamically adjusted to align them on a single vertical line?

For some time now, I have been grappling with a CSS issue. I am working with a table that has 3 columns displaying departures, times, and situational text for scenarios like delays or cancellations. However, as evident from the images, the alignment of th ...

Updating HTML using Angular JS with a nested dictionary is a breeze

As a newcomer to AngularJS, I am facing an issue with my code. I have created a dictionary in the controller scope and populated it after an HTTP request (key, value pair). The dictionary is being created successfully and there are no errors, but the HTML ...

I am looking to incorporate a feature in my form that allows for multiple file uploads and displaying them

Currently, I have a single file upload input field in my form and it works perfectly fine. However, I am looking to add multiple file inputs to the form as well. I have attempted various methods to integrate the code for multiple file uploads into my form, ...

aligning an image in the center of a webpage

I have created a simple HTML code to center an image inside the body of an HTML page. It works perfectly on Windows with various browsers, and on phones vertically when rotated. However, the issue arises when I open the site on a Mac as the centering doe ...

Response received from the server

I am looking to display server response error messages within a form after submission. By using the following code in my JavaScript, I am able to retrieve the error message: .error(function (data, status, header, config) { $scope.postDataSuccessfully ...

Retrieving Data from Database on the Current Page

Struggling with fetching data from a MySQL database using PHP search methods and displaying the results on the same page? Here's how you can achieve it. This HTML Script: <html> <head> <title>Digital Library</title> </head ...

React Native: Enhance the background with a vibrant stripe of color

I am trying to incorporate a strip of grey in the middle of my white background, but I am encountering an issue where I am unable to input any text inside it. Below is the code snippet I am working with: container: { flex: 1, justifyContent: "cent ...

Unable to discover a method to accomplish this task

Greetings to the Stack Overflow community! I have a scenario with two div blocks containing images of dimensions 1280px width and 700px height each. In the first block, there is a div with a width of 400px and a height of 100% floating left. The second ...

Issue with Angular: Unable to locate a differ that supports the object '[object Object]' of type 'object'. NgFor is only compatible with binding to Iterables such as Arrays

As someone who is new to Angular, I am facing a challenge while working on my portfolio project. The issue arises when trying to receive a list of nested objects structured like this: "$id": "1", "data": { &quo ...

Why is having <html lang="en"> essential?

Is the tag essential for website development? Will my code be impacted if I choose not to include it? ...

Tips for adjusting the up and down controls and spins of a date input after modifying its height

After adjusting the height of my inputs (date type) to 40px, I noticed that the up and down controls are no longer aligned with the text inside the field. I am looking for a solution to either adjust the height of the spins or remove them if necessary in ...

Can a drop shadow be achieved using only CSS3 without any additional tools or techniques?

Our designers love fancy drop shadows, but I prefer to avoid using image sprites. I am determined to create this effect using only CSS3. However, it's proving to be a challenge to replicate it perfectly with CSS3 alone: This is my attempt so far, but ...

Tips on customizing the selected icon color in Material-UI's BottomNavigationAction styling

I'm facing an issue with Material-UI styled components and could use some assistance. My goal is to create a BottomNavigation bar in React using Material-UI v5 where the selected option's icon displays in red (#f00) while the unselected icons sho ...

The HTTP.GET method seems to be malfunctioning

I'm having some trouble loading an image from a HTTP.GET request into my application. The picture just won't seem to display correctly. Any suggestions on what might be causing this issue? Below is the code I am using: HTML: <ion-view view- ...

none of the statements within the JavaScript function are being executed

Here is the code for a function called EVOLVE1: function EVOLVE1() { if(ATP >= evolveCost) { display('Your cell now has the ability to divide.'); display('Each new cell provides more ATP per respiration.'); ATP = ATP ...