ExtJs实现多选项卡的滚动效果

多选项卡的滚动效果图:

 

 
ExtJs实现多选项卡的滚动效果
 实现代码:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>多选项卡的滚动效果</title>
<script type="text/javascript" src="jquery.min.js"></script>
<style>
h1,h2,h3,h4,h5,h6,p,ol,ul,li,dl,dt,dd{padding:0;margin:0;}
li{list-style:none;}
img{border:none;}
u{text-decoration:none;}
em{font-style:normal;}
a{color:#424242;text-decoration:none;outline:none;blr:expression(this.onFocus=this.blur());}
body{font-size:12px;font-family: Arial,Verdana, Helvetica, sans-serif; word-break:break-all;}
.box{margin:0 auto;text-align:left;width:920px;}
.clear{clear:both;}
.contain{
	height:30px;
	width:240px;
	position:relative;
	overflow:hidden;
	float:left;
}
.tab{
	background:#eee;
	position:absolute;
	width:600px;
	left:0;
}
.tab li{
	float:left;
	background:#fff;
	color:#666;
	margin:4px;
	padding:2px;
	cursor:pointer;
}
.tab .active{
	background:#06c;
	color:#fff;
}
.prev,.next{
	float:left;
	display:block;
	height:25px;
	line-height:25px;
	border:solid 1px #ddd;
	background:#efefef;
	width:15px;
	font-family:宋体;
	text-align:center;
	cursor:pointer;
}
span.prev{
	left:200px;
	}
.dis{
	color:#ccc;
	cursor:auto;
}
.content{
	width:252px; 
	height:50px; 
	border:1px solid #ccc; 
	padding:10px; 
	clear:both
}
</style>
<script type="text/javascript">
$(function(){
	var current=1;
	var count=$('.tab li').length;
	$('.prev').addClass('dis');
	$('.next').click(function(){
		if(current<count-3){
		$('.next').removeClass('dis');
		$('.prev').removeClass('dis');
		$('.tab').animate({left:'-='+60},600);
		current++;
		$('.current').html(current);
		}
		if(current==count-3){
		$('.next').addClass('dis');
		}
	});
	$('.prev').click(function(){
		if(current>1){
		$('.next').removeClass('dis');
		$('.prev').removeClass('dis');
		$('.tab').animate({left:'+='+60},600);
		current--;
		$('.current').html(current);
		}
		if(current==1){
		$('.prev').addClass('dis');
		}
	});

   $('.content div:gt(0)').hide();
   $('.tab li:first').addClass('active');
   $('.tab li').click(
         function(){
           $(this).addClass('active').siblings().removeClass('active');
           $('.content div').eq($(this).index('.tab li')).siblings().hide().end().show();
                    }
   );
});
</script>
</head>
<body>
    <span class="current">1</span><br>
    <span class="prev">&lt;</span>
    <div class="contain">
        <ul class="tab">
            <li>tab1</li>
            <li>tab2</li>
            <li>tab3</li>
            <li>tab4</li>
            <li>tab5</li>
            <li>tab6</li>
            <li>tab7</li>
            <li>tab8</li>
        </ul>
    </div>
    <span class="next">&gt;</span>
	<div class="content">
        <div>1111111</div>
        <div>2222222</div>
        <div>3333333</div>
        <div>4444444</div>
        <div>5555555</div>
        <div>6666665</div>
        <div>7777777</div>
        <div>8888888</div>
	</div>

</body>
</html>

 

你可能感兴趣的:(ExtJs)