Without making assumptions about the number or height of the ticker items (except we assume that there are more than 2), you pretty much need to use javascript to set the size of #tickerwrap
. To make it responsive to window resizes, use jQuery's .resize()
with a time-delay.
So, add this code (See the demo):
function sizeTickerwrap () {
var tickerUL = $('#ticker');
var numTickerItems = tickerUL.children ('li').length;
if (numTickerItems < 3)
return;
//-- The second item will not be in a slide animation.
var itemHeight = tickerUL.children ('li:eq(1)').outerHeight (true);
//-- Adjust for the containing <ul>
var wrapHeightAdjst = tickerUL.outerHeight (true) - tickerUL.height ();
$("#tickerwrap").height (numTickerItems * itemHeight + wrapHeightAdjst);
}
//-- Initial call after a settling delay
setTimeout (sizeTickerwrap, 1200);
$(window).resize ( function () {
/*-- Time-delay the resize response to give browser a chance to settle
and avoid bogging down the UI.
*/
this.resizeTimer = this.resizeTimer || null;
if (this.resizeTimer)
clearTimeout (this.resizeTimer);
this.resizeTimer = setTimeout (sizeTickerwrap, 200);
} );