想要实现效果,点击时有滑动出导航条的效果。
实现代码
html代码
<ul class="tab">
<li>全部</li>
<li>福利</li>
<li>制度</li>
<li>管理</li>
<li>其他</li>
</ul>
js代码
var nowIndex=$('.tab li').index(this);
var leftRem = ( nowIndex - 1 > 0 ? nowIndex - 1 > 1 ? 1 : nowIndex - 1 : 0 ) * -2.4 + 'rem';
$(this).parent(".tab").animate({left:leftRem},300);