开发者

min-height does not work with body

开发者 https://www.devze.com 2023-01-16 21:09 出处:网络
Does min-height not work on body/html? body, html { min-height:100%; 开发者_开发知识库} Accomplishes absolutely nothing (firebug reports the body,html tags height does not change at all)First, decl

Does min-height not work on body/html?

body, html
{
    min-height:100%;
开发者_开发知识库}

Accomplishes absolutely nothing (firebug reports the body,html tags height does not change at all)


First, declare a doctype so you're in standards if you haven't already.

Now, the body can only be as high as the containing html, so you need to set HTML tag to 100% height, and body to min-height 100%. This works for me on Firefox.

html {height:100%} 
body {min-height:100%}


This worked for chrome 64 without setting a hard-coded height:

html {
    min-height: 100%;
    display: flex;
}

body {
    flex: 1;
}


Not all browsers like min-height, try something like this to catch all browsers.

  min-height:100%;
  height:auto !important;
  height:100%;


I solved the problem with just:

body {
    min-height: 100vh;
}


None of the above answers work for me.

What I did:

html, body {
  height: 100%;
  display: grid;
}


html{
  height:100%;
}
body{
  min-height:100%; 
  position:relative;
}

you must add

0

精彩评论

暂无评论...
验证码 换一张
取 消