0

I have a functional vertical jquery carousel as i have tweaked and modified the script and example found here: http://sorgalla.com/projects/jcarousel/examples/static_vertical.html

Instead of images, i am using text as list items. this script uses an fixed height style, and i am trying to incorporate an auto expand height feature. To collapse and expand based on the content within the li.

i have tried a few things with the css like setting certain elements to height:auto; or height:100%; but does not seem to work.

would anyone have a tidbit on where i should focus my attempts on how to make this auto expand and collapse based on content? should i be tweaking the javascript and not the CSS?

just looking for insight.

4

2 回答 2

0

这取决于您的轮播的工作方式,但您可能需要调整 javascript。

如果轮播需要具有固定高度的元素,您可以将内容写入元素,获取高度,然后将元素的高度显式设置为您刚刚找到的值。这样高度取决于内容,但它也是固定的而不是流动的,而且您也知道高度的值是多少。

像这样的东西可能会起作用:

var height = $("#my-li").css({'height':'auto'}).html('Some text content').height();
//do any calculations you need with height here
$("#my-li").css({'height':height+'px'})
于 2010-03-19T15:03:44.480 回答
0

抱歉,罗伊,我认为使用 javascript 可能会被认为是过度的和不好的做法,即使它有效。

我建议托尼申请

   li { display:block; overflow:hidden; width:blabla px;}

然后高度将根据内容强制增加和减少。

于 2010-03-19T15:13:40.347 回答