身高:100%神秘不工作 [英] height:100% mysteriously not working

查看:84
本文介绍了身高:100%神秘不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



关于 THIS 页面中,您可以注意到,蓝色区域并未随页面内容伸展高度,即使它被分配为具有以下CSS样式:

 身高:100%; 

任何帮助解决或试图理解这种行为?

body 元素上设置 height:auto ,解决方案

  body {
width:100%;
font-family:sans-serif;
height:auto;
}

更新
$ b

好的,尽管内容较少,但并不知道它需要100%。



您可以做的是,



给你的身体一些高度(比如1000px)。然后,您的部分的100%将展开至1000px。

PS: min-height 不起作用。您需要在 px em 中提供高度。



尽管我不太确定为什么元素无法确定100%的100px而不是100%的100%b $ b

I'm building some tests around height:100%.

On the THIS page you can notice the blue area doesn't stretch its height with the page content, even though it is assigned to have the CSS style of:

height:100%;

Any help on solving or trying to understand this behaviour?

解决方案

Set height: auto on your body element,

body {
  width: 100%;
  font-family: sans-serif;
  height: auto;
}

Update

Ok, wasn't aware it needs to be 100% despite lesser content.

What you can do is,

give your body some height (say 1000px). And then the 100% on your section will expand to 1000px.

PS: min-height won't work. You'll need to provide a height in px or em.

Although, I'm not very sure on why elements cant figure out 100% of 1000px and NOT 100% of 100%

这篇关于身高:100%神秘不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆