开发者

jQuery scrolling UL with hidden overflow

I have a UL with LI's set to display horizontally. The UL has a fixed width and it's set to hide the overflow. This is so I can display my images, which are to be used in a gallery, neatly. It works and looks nice.

I want to, however, use jQuery to scroll the contents of the UL rather than set the overflow property to auto and be presented with those ugly scroll bars. I recycled some code I used to do the same thing a few weeks back but, back then, I was doing it in DIV's. Much easier, apparently.

$('.gallery_container span').hover(
function开发者_JAVA百科()
{
   if ($(this).attr('class') == 'up')
      direction = '-=';
   else
      direction = '+=';

   var divOffset = $('ul.gallery').offset().top;
   $('ul.gallery').animate({scrollTop: direction + divOffset}, 5000);
},
function()
{
   $('ul.gallery').stop();
});

I saw a site that says the scrollTop property can be applied to UL's. So I'm not sure what exactly is causing this not to work.

Any ideas?

EDIT: Found what was causing it to not work at all but not it scrolls vertically - Kind of expected that. Is there any way to scroll it horizontally?


Perhaps:

$('ul.gallery').animate({scrollLeft: direction + divOffset},2000);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜