im trying to simulate a grid system, so i have a function `set_gridSize" which will set the background-image of the div to a grid. the output of the function sets the backgroubd image to a base64 encoded string that renders.
$.css({"background-image", "url(data:image/svg+xml;base64,"+encode(xml) +")"});
so i create this, and it looks create. the issue though is that when it scrolls, it doesnt scroll the image as well. I was thinking that it would.
is there something that i am doing wrong? Is there a concept for this that i am missing to address?
使用background-image
属性,您无法执行此操作,但是如果将另一个div
放置在原始div
,然后设置该div
的background-image
,则可以使用: Fiddle示例
Try using the background-attachment
property along with background-repeat
:
$.css({
"background-image": "url(data:image/svg+xml;base64,"+encode(xml) +")",
"background-attachment": "fixed",
"background-repeat": "no-repeat"});
This will keep the image where it originally started as you scroll the page.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.