简体   繁体   中英

How can I get my background showing in javascript css

im trying to use a background image within iScroll's javascript. The script seems to use css within the javascript and does allow me to add a background colour but not an image for some reason. Is there a way around this so that I can use an image?

here is the section of the code that im trying to get to show the background image (images/scrollbar_bg.png)

if (that.options.scrollbarClass) 
bar.className = that.options.scrollbarClass + dir.toUpperCase();

else bar.style.cssText = 'position:absolute;z-index:100; 
absolute; left: 0px; margin-left: 14px; background-url: images/scrollbar_bg.png; '

 + (dir == 'h' ? 'height:7px; bottom:20px; left:2px; right:
' + (that.vScrollbar ? '7' : '2') + 'px' : 'width:7px;bottom:' 
+ (that.hScrollbar ? '7' : '2') + 
'px;top:14px;right:1px -border-radius:3px;border-radius:3px');

Thanks

Where did you get background-url from? The correct syntax would be this:

background-image: url(images/scrollbar_bg.png);

Also, you have a random absolute; sitting in the middle of your z-index and left properties.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM