View Full Version : Text and Image Crawler specified width

08-10-2011, 03:44 PM
Is there a way that I can change the script that the width stays as it is specified in the CSS. I need the scrolling area to stay a specific width on my website even if it has a bit of an empty spot in it.:confused:

08-10-2011, 04:30 PM
Well it won't exactly make a gap. It will have a gap that gets filled in suddenly at one or more points is more like it.

And this should only be an issue if you've setup the crawler with a percent width and there's nothing to limit it from becoming wider than the width of the content of its division (it's text and/or image train).

If you have a fixed width, just add blank images,   characters, text or duplicates of what you do have to fill it out.

If what you're going for is like a crawling banner across the page, I'd suggest simply duplicating the content like 30 times or more so that it would be very unlikely that a gap could occur.

That all said, this version of the script removes the limitation on the width allowing the slightly erratic behavior described above if the width exceeds the content:


08-11-2011, 12:33 PM
Thanks John.

My problem is that I populate the crawler with text from a database (breaking news for a newspaper website), so I don't know the length. I willl look at the link you added.


08-11-2011, 01:42 PM
Then I don't see why you wouldn't want the crawler to shrink. If it's a layout issue, like if there's a certain amount of space that must get filled, you could center the crawler within that space, something like:

<div style="width: 500px;">
<div class="marquee" id="mycrawler"><?php echo $whatever; ?></div>
<script type="text/javascript">
uniqueid: 'mycrawler',
style: {
'padding': '5px',
'width': '100%',
'margin': '0 auto', //centers crawler inside its parent element
'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

That way it will always take up 500px or whatever you set the outer div to be, but if it doesn't have enough content to fill that out completely, it will shrink and center itself within that space.

Note: For IE less than 9, the margin 0 auto requires that the page have a standards invoking DOCTYPE in order to work at centering the crawler.