我正在处理一个元素,遇到了一个障碍,我似乎无法解决这个问题。 (哈哈,修复)
我有一个与 html、php 一致的页面 <?php include=""; ?>
、javascript(和 jQuery),当然还有一些 CSS。问题是 CSS。
首页有one background picture子页面有 another background picture .
子页面的图片应位于“右上角”,首页图片应以显示整个图片的方式放置。
当没有 background-attachment:
时它工作得很好已指定,但我有一个子页面,其文本多于该页面可以包含的文本。当然,这会使页面滚动。我希望图片不动(保持固定),但是当我向我的 background:
添加“固定”时在CSS中,图片变得疯狂。这是命令,我把我的东西放在background:
div#container {
background: #ccffff url("billder/bckground.jpg") fixed no-repeat right top;
}
我认为问题可能出在这里,但我尝试分隔标签,或者在 css 中调用的任何内容,如下所示:
background-color: #ccffff;
background-image: url("billeder/bckground.jpg");
background-attachment: fixed;
background-repeat: no-repeat;
background-position: right top;
仍然不工作(仍然狂野)
我使用 this method 构建页面使一个 div 有一个 min-height:
百分比。 This is the main page我的元素和this is the subpage有很多文字。如您所见,主页面变乱了,子页面的背景图片没有正常显示,您看不到整个图片。图片是已修复但未按我希望的方式显示。
我真的希望你能帮助我,因为我为这个网站付出了很多的努力。
为了避免任何误解和烦人的问题,我不是一个非常有经验的程序员/网络开发人员。
编辑
为了清楚起见,我想要的是背景保持固定(随页面滚动)
最佳答案
删除 fixed
并设置 min-height
(或 height
我认为看起来更好)到 750px
在你的 <div id="container_front">...</div>
.
所以它在你的 css 中变成了这个:
div#container {
position:relative;
margin:0 auto;
width:900px;
background-color: #ccffff;
background-image: url("billeder/bckground.jpg");
background-repeat: no-repeat;
background-position: right top;
background-attachment: fixed;
height: 750px;
min-height: 750px;
}
关于css - 背景图片不适用于固定附件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3533546/