我发现了一个相当奇怪的问题,我认为我知道如何解释它;我只是不知道如何修复它!
我有一个带有div#container(高度为100%min-height(IE的高度))的页面,其中包含标题、“page-content”和页脚。 div#container的背景图应该是固定的(而不是固定位置,而是 background-attachment: fixed 使图片跟随滚动)。
问题是,当CSS中添加固定附件的背景标签时,背景图片现在位于div外部。
CSS如下:(没有background-attachment: fixed;
)
div#container {
position:relative;
width:900px;
margin:0 auto;
background-color: #ccffff;
background-image: url("pics/sign.jpg");
background-repeat: no-repeat;
background-position: right top;
height:auto !important;
height:100%;
min-height:100%;
}
margin:0 auto;
用于居中div,而第一个height:
中的!important
作用是使IE忽略该特定高度标签。如果要使用min-height: 100%
则必须这样做。
当我添加了这个...
div#container {
position:relative;
width:900px;
margin:0 auto;
background-color: #ccffff;
background-image: url("pics/sign.jpg");
background-attachment: fixed; //This is what is added to the code-sample
background-repeat: no-repeat;
background-position: right top;
height:auto !important;
height:100%;
min-height:100%;
}
背景图片在
外面移动了。让我解释一下: 背景图像中唯一可见的部分是仍在
内部的部分,但部分图像已经移到
之外,现在不可见了。
简而言之...
当背景图片被固定时,它部分隐藏并在
外移动。该图片位置在浏览器窗口的右上角,而非
的右上角。
希望你们能帮帮我!