css背景修复了调整窗口大小后失败的问题

css背景修复了调整窗口大小后失败的问题,css,background,background-image,fixed,css-position,Css,Background,Background Image,Fixed,Css Position,我花了几个小时的时间试图把背景固定在中间。我希望你能指出我在哪里犯了愚蠢的错误 我的代码 #main_inside{ float:right; margin-top:223px; width:700px; background:url("images/gidas.png") no-repeat fixed 496px 259px transparent; margin-bottom: 86px; }

我花了几个小时的时间试图把背景固定在中间。我希望你能指出我在哪里犯了愚蠢的错误

我的代码

#main_inside{
        float:right;
        margin-top:223px;
        width:700px;    
        background:url("images/gidas.png") no-repeat fixed 496px 259px transparent;
        margin-bottom: 86px;
    }
问题是当我使用crtl+滚动重新调整窗口大小时。图像消失了

我也尝试过:

background-position:center;
并尝试了以下方法:

background-origin:content-box;
并尝试使用%设置图像距离

真正有问题的URL

当您使用“固定”时,您正在将图像固定到网站的视口(也称为窗口),因此,例如,如果您将其设置为“背景位置:左0”,它将不会采用div left位置,而是窗口的左位置。
这就是为什么当你调整窗口大小时,图像会移动。

我试过背景位置:左0,但运气不好。对于所有尺寸的窗户,将图片放置在中间是简单还是复杂的方法?我举了一个例子,它不会像你现在这样工作。一种简单的方法是将背景添加到body标记。(或者某个div占据了窗口宽度的100%)我不确定这个设计有什么问题,但即使我把它添加到主体上,它也不起作用