最小高度不适用于身体

时间:2022-07-15 17:54:34

Does min-height not work on body/html?

min-height对body / html不起作用吗?

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

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

绝对没有任何结果(firebug报告身体,html标签高度根本没有变化)

4 个解决方案

#1


52  

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

首先,声明一个doctype,如果你还没有,那么你就是标准。

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一样高,所以你需要将HTML标记设置为100%高度,并将body设置为min-height 100%。这适用于Firefox。

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

#2


6  

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

并非所有浏览器都像min-height一样,尝试这样的东西来捕获所有浏览器。

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

#3


5  

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

这适用于chrome 64而不设置硬编码高度:

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

body {
    flex: 1;
}

#4


0  

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

you must add

你必须添加

#1


52  

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

首先,声明一个doctype,如果你还没有,那么你就是标准。

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一样高,所以你需要将HTML标记设置为100%高度,并将body设置为min-height 100%。这适用于Firefox。

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

#2


6  

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

并非所有浏览器都像min-height一样,尝试这样的东西来捕获所有浏览器。

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

#3


5  

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

这适用于chrome 64而不设置硬编码高度:

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

body {
    flex: 1;
}

#4


0  

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

you must add

你必须添加