PDA

View Full Version : Image Crawler with Background Image



krueemel
09-17-2010, 04:45 PM
1) Script Title: Text and Image Crawler

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex2/crawler/index.htm

3) Describe problem: Is it possible to set a picture instaed of a color as background?

At the moment you can only change the color in hex code. I would like to set an background image. But how?

greets,
krueemel

jscheuer1
09-17-2010, 05:16 PM
That's not true. You can use almost any style property/value pairs you like. Where you have something like so to initialize the crawler (from Step 2 on the demo page):


<script type="text/javascript">
marqueeInit({
uniqueid: 'mycrawler',
style: {
'padding': '5px',
'width': '450px',
'background': 'lightyellow',
'border': '1px solid #CC3300'
},
inc: 8, //speed - pixel increment for each iteration of this marquee's movement
mouse: 'cursor driven', //mouseover behavior ('pause' 'cursor driven' or false)
moveatleast: 4,
neutral: 150,
savedirection: true
});

The highlighted is known as a style object. It will be parsed into actual style and applied dynamically to the crawler. So you can put anything (within reason) that you like there. Adding a background image is fine, example:


style: {
'padding': '5px',
'width': '450px',
'background': 'lightyellow url(myimage.jpg)',
'border': '1px solid #CC3300'
},

or:


style: {
'padding': '5px',
'width': '450px',
'background-image': 'url(myimage.jpg)',
'border': '1px solid #CC3300'
},

Just be sure to follow the quoting convention of the style object (also from the demo page):


Style object for this marquee container (use quotes on both sides of the : as shown) (defaults to {'margin': '0 auto'}, which centers a marquee) If no width is specified it will default to 100%, if no height is specified, it will default to the offsetHeight of the marquee contents. Marquees whose specified or default width is greater than their contents will be automatically shrunk to avoid empty spots.

krueemel
09-18-2010, 11:46 AM
thank you very much!
i didn't know, thats it is so easy to set an image as background.

It is a very nice and good script.

greetz,
krueemel :)