当前位置:编程学习 > JS >>

仿QQ迷你首页的左右滚动Tab选项卡

仿QQ迷你首页的左右滚动Tab选项卡,只是实现了关键的左右滚动,至于选项卡可以修改一下,这里主要是发出大家比较关注的左右控制滚动。
答案:<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>滚动Tab</title>
<style type="text/css">
div#box{
	float:left;
	}
div#box span{
	display:block;
	cursor:pointer;
	width:24px;
	height:24px;
	}
div#box span#left{
	float:left;
	background:transparent url(http://www.zzzyk.com/jscss/demoimg/200906/all2008.gif) no-repeat scroll left -82px;
	}
div#box span#right{
	float:left;
	background:transparent url(http://www.zzzyk.com/jscss/demoimg/200906/all2008.gif) no-repeat scroll -384px -82px;
	}
div#qqmini{
	float:left;
	width:345px;
	overflow:hidden;
	}
ul{
	margin:0px;
	float:left;
	width:9999px;
	overflow:hidden;
	margin-left:-2.5em;
	*margin-left:-1px;
	}
li{
	list-style-type:none;
	float:left;
	background:transparent url(http://www.zzzyk.com/jscss/demoimg/200906/all2008.gif) no-repeat scroll 0 -31px;
	width:69px;
	height:18px;
	padding-top:5px;
	text-align:center;
	cursor:pointer;
	}
</style>
</head>
<body>
<div id="box">
<span id="left"><a href="javascript:void(0)"></a></span>
<div id="qqmini">
<UL>
	<LI>新闻</LI>
	<LI>财经</LI>
	<LI>娱乐</LI>
	<LI>体育</LI>
	<LI>汽车</LI>
	<LI>读书</LI>
	<LI>博客</LI>
	<LI>游戏</LI>
</UL>
</div>
<span id="right"><a href="javascript:void(0)"></a></span>
</div>
<script type="text/javascript">
function $(e){
return typeof e == 'string'?document.getElementById(e):e;
}
var Event={
	add:function (obj,EventType,fn){
	if (obj.attachEvent){
		obj['e'+EventType+fn] = fn;
		obj[EventType+fn] = function() {obj['e'+EventType+fn](window.event);}
		obj.attachEvent('on'+EventType,obj[EventType+fn]);
		}else if(obj.addEventListener){
			obj.addEventListener(EventType,fn,false);	
			}else	{
				obj['on'+EventType]=fn;
				}
	}
	,
	remove:function(obj,EventType,fn){
	if (obj.detachEvent){
		obj.detachEvent('on'+EventType,obj[EventType+fn]);
		}else if(obj.removeEventListener){
			obj.removeEventListener(EventType,fn,false);
			}else	{
				obj['on'+EventType]=null;
				}
	
	}
}
function set(l,r,c,offset){
	Event.add(l,'click',function (){c.scrollLeft-=offset});
	Event.add(r,'click',function (){c.scrollLeft+=offset});
	}
set($('left'),$('right'),$('qqmini'),69);
</script>
</body>
</html>

上一个:又一淘宝网的TAB选项卡,很圆滑
下一个:简单、清新CSS水平菜单

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,