我有一个网站,在我的一个网页中,我使用了一个看起来像编辑器的div。我可以在这个div和上面的内容中有一个背景。当我在div中滚动时,我希望此背景保持固定位置。如何在div中修复背景?
我的代码是与此类似:
<div id="myEditorArea" style="vertical-align: top; width: 240px; height: 320px; background-image: url('image.png'); background-repeat: no-repeat; background-position: center center; background-attachment:fixed; overflow:scroll; text-align: left;">
bla bla bla
</div>
背景保持固定的,当我滚动DIV中工作正常。问题在于,当我在整个页面中滚动时,它正在移动。
有谁知道可能是什么问题?
预先感谢
您可以链接到页面,我不知道我理解这个问题。 –
你忘了结束'style =“...”'。你写了'style =“...' – kongr45gpen
这个页面有点复杂,我有一个例子,我发现这个链接http://www.quackit.com/html/codes/html_background_codes.cfm和我想要做同样的事情,就像他为固定背景图像做的一样。我的问题是,当我滚动整个页面而不是只在这个div内时,这个图像正在移动。 – novellino