Home » Html » Why is min-height not working?

Why is min-height not working?

Posted by: admin November 30, 2017 Leave a comment

Questions:

So here’s the scoop.

I have a gradient applied to the background of the body element. Then I have a container (right after body) that has a background .png image applied to it. The gradient always expands to at least 100% window height but the container (#body2) does not.

Any suggestions to why this doesn’t work? You can inspect the HTML on my web page here: http://www.savedeth.com/parlours/

Answers:

Specify height: 100% on the html, body and #body2 elements (line 1358).

html, body, #body2
{
    height: 100%;
    min-height: 100%;
}

Not tested in IE 6, works in 7 though.

Questions:
Answers:

Using vh instead of % worked for me without having to use any extra tricks.

This is what I have:

html, body, .wrapper {
    min-height: 100vh;
}

Where .wrapper is the class you apply to your container/wrapper or main body of content that you wish to stretch the full length of the screen height.

This will work as you would expect it to when the content within the wrapper is less or more than the screen height allows.

This should work in most browsers.

Questions:
Answers:

You have your min-height set to 100% which will only be as tall as any elements that fill the space. Express you min-height in terms of pixels. Also, note that IE6- requires it’s own set of rules. See http://davidwalsh.name/cross-browser-css-min-height for more details.

Questions:
Answers:

position: absolute; works in most cases

Questions:
Answers:

something is setting the height of your body element to 320px (if you look in chrome’s inspect element)

therefore 100% is of 320px. that is why is it only showing on the top of the page with 100% of 320 px height.

you have to set a height for the min-height to work.

so set the height @ 100% in general should work.

Questions:
Answers:

Screw it. Who doesn’t have javascript anyways? Especially for this demographic.

<script type="text/javascript">
$(document).ready(function(){
if($("body").height() < $(window).height()){
    $("body").height($(window).height());
}
});
</script>