【发布时间】:2014-05-27 03:57:55
【问题描述】:
我一直在尝试制作一组很酷的列表,一次显示一个项目。但是,如果我使用下一种方法这样做,它就会变得缓慢而滞后。有没有办法顺利做到这一点?
这是 CodePen 的东西和下面的代码:
HTML (emmet)
(.outer>(ul#list$>(li.left>h3{title$})+(li.center>p{some text})+(li.right>p{some other text}))*5)+button#show{SHOAW}
SCSS
$height: 50px;
*{box-sizing:border-box}
body{font-family:sans-serif}
.outer{
width:100%;
ul{
width:100%;
list-style:none;
padding:0;
margin:0;
height:$height;
li{
float:left;
width: (100%/3);
background-color: whitesmoke;
height:$height;
border-left:solid thin #e1e1e1;
text-align:center;
&.center, &.right {
display:none;
}
&:first-child{
border-left:none;
}
}
}
}
jQuery
$(document).ready(function() {
$('#show').click(function() {
$('.center, .right').first().show('fast', function showNext () {
$('.outer ul *').next('.center, .right').show('fast', showNext);
});
});
});
【问题讨论】:
-
这听起来很奇怪但很准确 - codepen.io/anon/pen/BAkah - 它在某个地方出现了错误 - 但我现在没有时间修复它 - 也许你会有更好的运气! :D 将其视为提示! :)
-
你试过 $($(SELECTOR).nextAll(SELECTOR)[0]) 或 $(SELECTOR).nextAll().first()
-
谢谢,伙计们!我和一个朋友一起解决了这个问题,但我彻底测试了你的想法。不过,可能超出了我的想象。