CSS高度问题 [英] CSS Height problem

查看:75
本文介绍了CSS高度问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我遇到高度问题(正如你可能从标题中猜到的那样)。


我原来的问题是背景在Internet Explorer中没有正确对齐,但它在Firefox中完成。为了尝试修复此问题,我删除了正文背景并添加了一个位于0,0的div,其宽度和高度均为100%。问题是,100%是指浏览器的高度,而不是页面的高度。一旦页面超出浏览器的高度,背景就会停止。我怎么能阻止这个?或者我怎么能修复背景对齐?

解决方案

这取决于。没有完整的代码或链接,我们只能猜测。但是在你的CSS中尝试这个:


html,body {

身高:100%;

宽度:100%;

}






我遇到了麻烦高度(正如你可能从标题中猜到的那样)。


我原来的问题是背景在Internet Explorer中没有正确对齐,但它在firefox中完成了。为了尝试修复此问题,我删除了正文背景并添加了一个位于0,0的div,其宽度和高度均为100%。问题是,100%是指浏览器的高度,而不是页面的高度。一旦页面超出浏览器的高度,背景就会停止。我怎么能阻止这个?或者我怎么能修复背景对齐?



你可以使用CSS来重复背景

展开 | 选择 | 换行 | 行号


< blockquote>是的我有一个重复的背景,这很容易,但它不与IE 6页面上的任何其他元素内联。例如,我有一个中心对齐的背景图像,它是960x32px。我使用< img>在位置50%,0px处绘制该图像,边距为-480px,因此它使图像居中。这适用于FF,但在IE中,它似乎是一个像素。然后,当我调整IE窗口的大小时,它就会消失。看起来元素以窗口为中心,背景居中于其他东西= S.一个看似显而易见的解决方案是将身体移动到50%但宽度是多少从边缘减去? 50%?只是取消了。


Hi,

I am having trouble with height (as you may have guessed from the title).

My original problem was the background did not align correctly in internet explorer but it did in firefox. To try and fix this i removed the body background and added a div positioned at 0,0 with a width and height of 100% behind everything. The problem is, 100% refers to the browsers height, not the pages height. Once the page goes beyond the height of the browser, the background stops. How could I prevent this? Or how else could I fix the background aligning?

解决方案

It depends. Without the complete code or a link, we can only guess. But try this in your CSS:

html,body{
height:100%;
width:100%;
}


Hi,

I am having trouble with height (as you may have guessed from the title).

My original problem was the background did not align correctly in internet explorer but it did in firefox. To try and fix this i removed the body background and added a div positioned at 0,0 with a width and height of 100% behind everything. The problem is, 100% refers to the browsers height, not the pages height. Once the page goes beyond the height of the browser, the background stops. How could I prevent this? Or how else could I fix the background aligning?

You can use CSS to have a repeating background

Expand|Select|Wrap|Line Numbers


Yes i have a repeating background, thats easy stuff but it isnt inline with any other elements on the page in IE 6. For example, I have a center aligned background image which is 960x32px. I use <img> to draw that image at postion 50%, 0px with a margin-left of -480px so it centers the image. This works in FF but in IE, it appears to be a pixel out. Then when i resize the IE window, it goes way out. It appears that the elements are centered to the window, the background is centered to something else =S. A seemingly obvious solution is to move the body to 50% but whats the width to subtract from the margin? 50%? that just cancels out.


这篇关于CSS高度问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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