XHTML HTML元素的高度为100%,从而导致滚动条 [英] XHTML HTML element with 100% height causing scrollbars

查看:121
本文介绍了XHTML HTML元素的高度为100%,从而导致滚动条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的CSS文件中,我使用了这个:

  html,body {height:100%; padding:0; margin: 0; border:0;} 

导致垂直滚动条出现在IE8,Chrome 5和Mozilla上3.6,所有最新版本。

另外,文档是空的,它只有html,head和body标签,所以没有任何东西会出现在屏幕之外。 / p>

设置溢出:隐藏; html元素将完全停止在页面上滚动。



如何让它消失,请在内容高于显示高度时继续滚动?



谢谢。

解决方案

我可以有百分之百的div元素。

无论如何,我找到了答案:

只有这个问题当最顶部的元素有顶部边距时发生。
看起来上边距被增加到100%的高度,使其更高,并导致滚动条。



因此,要么使用填充顶部来隔开顶部大多数元素,或者在标签和具有顶部边距的下一个元素之间使用没有顶部边距的元素。


In my CSS file I use this:

html,body{height:100%;padding:0;margin:0;border:0;}

Which causes a vertical scrollbar to appear on IE8, Chrome 5 and Mozilla 3.6, all latest version.

Also, the document is empty, it only has the html, head and body tags so nothing is going out of screen to cause that.

Setting overflow:hidden; on the html element will completly stop scrolling on the page.

How can I make it go away please but also keep scrolling when content is higher than display height?

Thank you.

解决方案

I need 100% height in a XHTML document so that I can have div elements with 100%.

Anyway, I found the answer:

This problem only occurs when the top most element has a top margin. It seems that that top margin gets added to the 100% height making it higher and causing the scrollbar.

So either use padding-top to space the top most element or use a with no top margin between the tag and the next element with a top margin.

这篇关于XHTML HTML元素的高度为100%,从而导致滚动条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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