背景附件的 CSS 问题:已修复;
我有一个 Joomla 网站,我创建了一个自定义主题。该网站是 http://esn.teipir.gr/。
我左右有两个图像,我希望它们固定背景图像。
我使用以下 CSS 规则
div.backgroundboxleft {
background-attachment: fixed;
background-image: url("/images/back_1.png");
float: left;
height: 822px;
top: 40px;
width: 457px;
}
,
div.backgroundboxright {
background-attachment: fixed;
background-image: url("/images/back_2.png");
float: right;
height: 822px;
top: 40px;
width: 457px;
}
如果我删除背景附件,图像一切正常,但是当我使用 firebug 添加以下代码时,一切都会变得混乱。你能帮助我使页面保持固定,而不需要背景颜色位于顶部图像?
谢谢
I have a Joomla site that i have created a custom theme. The site is http://esn.teipir.gr/.
I have two images right and left that i want them to have background image fixed.
I use the following CSS rules
div.backgroundboxleft {
background-attachment: fixed;
background-image: url("/images/back_1.png");
float: left;
height: 822px;
top: 40px;
width: 457px;
}
and
div.backgroundboxright {
background-attachment: fixed;
background-image: url("/images/back_2.png");
float: right;
height: 822px;
top: 40px;
width: 457px;
}
If i remove the background-attachment all is OK with the images but when i add with firebug the following code everything messes up.Can you help me making the pages stay fixed without the background color being on top of the image?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您设置
background-attachment:fixed
时,它会修复与窗口相关的背景。因此,您需要调整图像的背景位置,以便它们出现在正确的位置。如果您将background
属性替换为下面的 css,它将正确排列。实例:http://jsfiddle.net/tw16/6fZ96/embedded/result/
澄清一下
background-attachment:fixed
会阻止背景随窗口滚动。因此,如果您的视口太小并且您必须水平或垂直滚动,背景将不会移动(即它将重叠)。更多信息可以在此处找到。When you set
background-attachment:fixed
it fixes the background in relation to the window. So you would then need to adjust thebackground-position
of your images so they appear in the right place. If you replace yourbackground
properties with the css below it will line up properly.Live example: http://jsfiddle.net/tw16/6fZ96/embedded/result/
To clarify
background-attachment:fixed
stops the background from scrolling with the window. So if your viewport is too small and you have to scroll horizontally or vertically the background will not move (i.e. it will be overlapped). More information can be found here.