xml/HTML代码
- <!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>选项卡 - Zehee</title>
- <script type="text/javascript" src="jquery/jquery.js"></script>
- <script type="text/javascript">
- jQuery(function($){
- /*Ztabs函数 - By Zehee*/
- function Ztabs(Tid,TitleOn,Cont,M){
- // Zehee - Tabs参数解释。
- // Tid - 选项卡外层ID,页面中唯一的钩子。
- // TitleOn - 选项卡选中时的class样式名称。
- // Cont - 内容区的class样式名称。
- // M - 选项之间的间距插补。
- var titles = $(Tid).children("h2");
- $(Tid).css({position:"relative"});
- titles.css({position:"absolute",top:"0",zoom:"100%"});
- $(Tid).children("div").addClass(Cont).hide();
- $(Tid).children("div:first").show();
- if(!titles.hasClass(TitleOn)){
- $(Tid).children("h2:first").addClass(TitleOn);
- }
- titles.each(function(){
- $(this).bind("click",function(){ //可更换为Mouseover形式
- titles.removeClass(TitleOn);
- $(this).addClass(TitleOn);
- $(Tid).children("div").hide();
- $(this).next("div").show("slow"); // 可更换为其他动画形式
- });
- });
- for(var i = 1;i < titles.length;i ++){
- $(titles[i]).css("left",$(titles[i-1]).offset().left - $(Tid).offset().left + $(titles[i-1]).width() + M + "px")
- }
- }
- $("#tabs").ready(function(){Ztabs("#tabs","on","cont",50);}) // 在此可添加多组选项卡
- /*动态添加标签项示例 - By Zehee*/
- function Addnav(ButtId,TabId){
- $(ButtId).click(function(){
- $(TabId).append("<h2>新标签</h2><div>新内容</div>");
- Ztabs("#tabs","on","cont",50);
- });
- }
- Addnav("#addnav","#tabs");
- });
- </script>
- <style type="text/css">
- <!--
- * { margin: 0px; padding: 0px; }
- body { padding:200px }
- p { padding:5px }
- #tabs { border:1px solid #fff; position: relative;}
- #tabs h2 { border:1px solid #ccc; font: normal 12px/30px Arial, Helvetica, sans-serif; height:30px; padding:0 20px; border-bottom-width:0px; color: #666666; }
- #tabs .on { border-color:#036;font-weight: bold; background:#D9ECFF; color: #003366; }
- #tabs .cont { border:1px solid #036; margin-top:30px; padding:20px; background:#D9ECFF; font-size: 12px; line-height: 20px; }
- -->
- </style>
- </head>
- <body>
- <p>
- <input type="button" id="addnav" value="添加标签项" />
- </p>
- <div id="tabs">
- <h2>每日新闻</h2>
- <div>百度董事长兼CEO李彦宏在上海出席一个投资年会时表示,百度近年增加了IM、贴吧等产品,是为增加用户粘度,不偏离搜索方向,这也是百度与谷歌雅虎的区别之一。 他指出,百度的目标是提供最好方式,让人们找到信息,搜索引擎仍是最有效方式,过去一年与可预见未来,搜索都将是百度最重要业务。</div>
- <h2>网络直通车</h2>
- <div>3月18日消息,据国外媒体报道,Google CEO埃里克·施密特本周一表示,Google担心微软每一起像雅虎这样规模的并购交易。</div>
- <h2>电影秀</h2>
- <div>第二届亚洲电影大奖昨晚在香港落幕,梁朝伟凭借《色,戒》中的表演摘得影帝桂冠。</div>
- <!--在此添加 <h2>新标签</h2> <div>内容</div> 即可扩展新标签项-->
- </div>
- </body>
- </html>



