带有二级菜单的滑动门效果

又是 CSSplay ,这个众多网页设计师心目中的圣地,总能带给我们诸多惊喜,Stu Nicholls 那富有创意并且高超的技巧,总能让一个个在我们看来不能实现的愿望变为现实。本文介绍的是他用 CSS 技术实现的带有二级菜单的滑动门效果,相信许多人期待已久了。

带有二级菜单的滑动门效果 – 示例

 
<style type="text/css">
/* ================================================================ 
This copyright notice must be untouched at all times.
 
The original version of this stylesheet and the associated (x)html
is available at http://www.cssplay.co.uk/menus/doors_drop_line_three.html
Copyright (c) 2005-2007 Stu Nicholls. All rights reserved.
This stylesheet and the associated (x)html may be modified in any 
way to fit your requirements.
=================================================================== */
 
/* for this demo only */
#nav {margin:20px 0 80px 0;}
 
/* the styling */
#nav {
	float:left; 
	width:650px; 
	height:auto; 
	background:#fff url("bottom_line.gif") repeat-x bottom; 
	position:relative;
}
 
#nav .select, #nav .current {
	margin:0; 
	padding:0; 
	list-style:none; 
	display:block;
}
 
#nav li {
	display:inline; 
	margin:0; 
	padding:0;
	height:auto;
}
 
#nav .select a,
#nav .current a {
	display:block; 
	height:21px; 
	float:left; 
	background: url("left_blue.gif") no-repeat left top; 
	padding:0 0 0 3px; 
	border-bottom:1px solid #000; 
	text-decoration:none; 
	font-size:10px; 
	line-height:20px; 
	white-space:nowrap; 
	margin-left:2px;
}
* html #nav .select a, * html #nav .current a {width:1px;}
 
#nav .select a b, 
#nav .current a b {
	height:100%; 
	display:block; 
	background:url("right_blue.gif") no-repeat right top; 
	padding:0 6px 0 3px; 
	color:#000;
}
 
#nav .select a:hover, 
#nav .select li:hover a {
	background-position:0 -75px; 
	border-color:#046; 
	cursor:pointer;
}
 
#nav .select a:hover b, 
#nav .select li:hover a b {
	background-position:100% -75px; 
	border-color:#046; color:#fff;
}
 
#nav .sub {display:none;}
 
/* for IE5.5 and IE6 only */
#nav table {
	position:absolute; 
	border-collapse:collapse; 
	left:0; 
	top:0; 
	font-size:11px;
}
 
#nav .current a {
	background-position:0 -75px; 
	border-color:#046;
}
#nav .current a b {
	background-position:100% -75px; 
	color:#ff6;
}
 
 
#nav .sub li a:hover, 
#nav .select a:hover .sub li a:hover, 
#nav .select li:hover .sub li a:hover {
	background:#005984 url("sub_sep.gif") top right no-repeat; 
	color:#fff; 
	text-decoration:underline;
}
 
#nav .sub_active .current_sub a, 
#nav .sub_active a:hover {
	background:#005984 url("sub_sep.gif") top right no-repeat; 
	color:#ff6; 
	text-decoration:underline;
}
 
#nav .select li a:hover .sub, 
#nav .select li:hover .sub {
	display:block; 
	position:absolute; 
	width:650px; 
	top:21px; 
	left:0; 
	background:#005984; 
	margin-top:1px; 
	padding:0; 
	z-index:100; 
	border-bottom:20px solid #fff;
}
 
#nav .sub, #nav .sub_active {
	margin:0; 
	padding:0; 
	list-style:none;
}
#nav .sub_active {
	display:block; 
	position:absolute; 
	width:650px; 
	top:21px; 
	left:0; 
	background:#005984; 
	margin-top:1px; 
	padding:0; 
	z-index:10; 
	color:#000; 
	border-bottom:20px solid #fff;
}
* html #nav .sub_active, * html #nav .select a:hover .sub {
	z-index:-1; 
	margin-top:0; 
	margin-top:1px;
}
 
#nav .sub_active a {
	height:25px; 
	float:left; 
	text-decoration:none; 
	line-height:24px; 
	white-space:nowrap; 
	font-weight:normal;
}
#nav .sub_active a, 
#nav .select a:hover .sub li a, 
#nav .select li:hover .sub li a {
	display:inline; 
	background:#005984 url("sub_sep.gif") top right no-repeat; 
	padding:0 10px; 
	margin:0; 
	font-size:10px; 
	width:auto; 
	white-space:nowrap; 
	font-weight:normal; 
	border:0; 
	color:#fff; 
	height:25px; 
	line-height:24px; 
}
</style>
 
<div id="nav">
 
 
<ul class="select"><li><a href="#"><b>January</b>
<!--[if IE 7]><!--></a><!--<![endif]--><!--[if lte IE 6]><table><tr><td><![endif]--><ul class="sub"><li><a href="#">Fish</a></li>
<li><a href="#">Chips</a></li>
<li><a href="#">Bacon</a></li>
<li><a href="#">Eggs</a></li>
<li><a href="#">Tomato</a></li>
</ul>
<!--[if lte IE 6]></td></tr></table></a><![endif]--></li></ul>
 
 
<ul class="select"><li><a href="#"><b>February</b>
<!--[if IE 7]><!--></a><!--<![endif]--><!--[if lte IE 6]><table><tr><td><![endif]--><ul class="sub">
<li><a href="#">Sausages</a></li>
<li><a href="#">Fried Bread</a></li>
<li><a href="#">Fillet steak</a></li>
<li><a href="#">Mushrooms</a></li>
</ul>
<!--[if lte IE 6]></td></tr></table></a><![endif]--></li></ul>
 
 
<ul class="select"><li><a href="#"><b>March</b>
<!--[if IE 7]><!--></a><!--<![endif]--><!--[if lte IE 6]><table><tr><td><![endif]--><ul class="sub"><li><a href="#">Lager</a></li>
<li><a href="#">Beer</a></li>
<li><a href="#">Red wine</a></li>
<li><a href="#">Crisps</a></li>
<li><a href="#">Brandy</a></li>
</ul>
<!--[if lte IE 6]></td></tr></table></a><![endif]--></li></ul>
 
 
<ul class="select"><li><a href="#"><b>April</b>
<!--[if IE 7]><!--></a><!--<![endif]--><!--[if lte IE 6]><table><tr><td><![endif]--><ul class="sub"><li><a href="#">Tea</a></li>
<li><a href="#">Coffee</a></li>
<li><a href="#">Milk</a></li>
<li><a href="#">Squash</a></li>
<li><a href="#">Lemonade</a></li>
</ul>
<!--[if lte IE 6]></td></tr></table></a><![endif]--></li></ul>
 
 
<ul class="current"><li><a href="#"><b>May</b>
</a></li></ul><ul class="sub_active"><li><a href="#">Crab</a></li>
<li><a href="#">Shrimps</a></li>
<li><a href="#">Lobster</a></li>
<li class="current_sub"><a href="#">Prawns</a></li>
<li><a href="#">Salmon</a></li>
</ul>
 
 
<ul class="select"><li><a href="#"><b>June</b>
<!--[if IE 7]><!--></a><!--<![endif]--><!--[if lte IE 6]><table><tr><td><![endif]--><ul class="sub"><li><a href="#">Jam</a></li>
<li><a href="#">Lemon Curd</a></li>
<li><a href="#">Marmalade</a></li>
<li><a href="#">Marmite</a></li>
<li><a href="#">Bovril</a></li>
</ul>
<!--[if lte IE 6]></td></tr></table></a><![endif]--></li></ul>
 
 
<ul class="select"><li><a href="#"><b>July</b>
<!--[if IE 7]><!--></a><!--<![endif]--><!--[if lte IE 6]><table><tr><td><![endif]--><ul class="sub"><li><a href="#">Lamb</a></li>
<li><a href="#">Chicken</a></li>
<li><a href="#">Pork</a></li>
<li><a href="#">Beef</a></li>
<li><a href="#">Cheese</a></li>
</ul>
<!--[if lte IE 6]></td></tr></table></a><![endif]--></li></ul>
 
 
<ul class="select"><li><a href="#"><b>August</b>
<!--[if IE 7]><!--></a><!--<![endif]--><!--[if lte IE 6]><table><tr><td><![endif]--><ul class="sub"><li><a href="#">Beach</a></li>
<li><a href="#">Country walk</a></li>
<li><a href="#">Photography</a></li>
<li><a href="#">Window shopping</a></li>
<li><a href="#">Gardening</a></li>
</ul>
<!--[if lte IE 6]></td></tr></table></a><![endif]--></li></ul>
 
 
<ul class="select"><li><a href="#"><b>September</b>
<!--[if IE 7]><!--></a><!--<![endif]--><!--[if lte IE 6]><table><tr><td><![endif]--><ul class="sub"><li><a href="#">Tulips</a></li>
<li><a href="#">Sunflower</a></li>
<li><a href="#">Cyclamen</a></li>
<li><a href="#">Dahlia</a></li>
<li><a href="#">Gladiolus</a></li>
</ul>
<!--[if lte IE 6]></td></tr></table></a><![endif]--></li></ul>
 
 
<ul class="select"><li><a href="#"><b>October</b>
<!--[if IE 7]><!--></a><!--<![endif]--><!--[if lte IE 6]><table><tr><td><![endif]--><ul class="sub"><li><a href="#">Cup</a></li>
<li><a href="#">Saucer</a></li>
<li><a href="#">Plate</a></li>
<li><a href="#">Fruit bowl</a></li>
<li><a href="#">Egg cup</a></li>
</ul>
<!--[if lte IE 6]></td></tr></table></a><![endif]--></li></ul>
 
 
</div>

您可以通过下面的链接访问 cssplay 原页面:
http://www.cssplay.co.uk/menus/doors_drop_line_three.html

Javascript 标签页(TAB)浏览控件推介之:DOMTab

如何在越来越显得狭小的页面空间上显示更多内容?相信很多人立即想到的就是标签页(TAB),她允许在同一个地方显示多个内容。标签页有很多种制作方法,本文介绍的是 Christian Heilmann 写的 DOMTab。

Javascript 标签页(TAB)浏览控件推介之:DOMTab – 示例

 
/*
	DOMtab Version 3.1415927
	Updated March the First 2006
	written by Christian Heilmann
	check blog for updates: http://www.wait-till-i.com	
	free to use, not free to resell
*/
 
domtab={
	tabClass:'domtab', // class to trigger tabbing
	listClass:'domtabs', // class of the menus
	activeClass:'active', // class of current link
	contentElements:'div', // elements to loop through
	backToLinks:/#top/, // pattern to check "back to top" links
	printID:'domtabprintview', // id of the print all link
	showAllLinkText:'show all content', // text for the print all link
	prevNextIndicator:'doprevnext', // class to trigger prev and next links
	prevNextClass:'prevnext', // class of the prev and next list
	prevLabel:'previous', // HTML content of the prev link
	nextLabel:'next', // HTML content of the next link
	prevClass:'prev', // class for the prev link
	nextClass:'next', // class for the next link
	init:function(){
		var temp;
		if(!document.getElementById || !document.createTextNode){return;}
		var tempelm=document.getElementsByTagName('div');		
		for(var i=0;i<tempelm.length;i++){
			if(!domtab.cssjs('check',tempelm[i],domtab.tabClass)){continue;}
			domtab.initTabMenu(tempelm[i]);
			domtab.removeBackLinks(tempelm[i]);
			if(domtab.cssjs('check',tempelm[i],domtab.prevNextIndicator)){
				domtab.addPrevNext(tempelm[i]);
			}
			domtab.checkURL();
		}
		if(document.getElementById(domtab.printID) 
		   && !document.getElementById(domtab.printID).getElementsByTagName('a')[0]){
			var newlink=document.createElement('a');
			newlink.setAttribute('href','#');
			domtab.addEvent(newlink,'click',domtab.showAll,false);
			newlink.onclick=function(){return false;} // safari hack
			newlink.appendChild(document.createTextNode(domtab.showAllLinkText));
			document.getElementById(domtab.printID).appendChild(newlink);
		}
	},
	checkURL:function(){
		var id;
		var loc=window.location.toString();
		loc=/#/.test(loc)?loc.match(/#(w.+)/)[1]:'';
		if(loc==''){return;}
		var elm=document.getElementById(loc);
		if(!elm){return;}
		var parentMenu=elm.parentNode.parentNode.parentNode;
		parentMenu.currentSection=loc;
		parentMenu.getElementsByTagName(domtab.contentElements)[0].style.display='none';
		domtab.cssjs('remove',parentMenu.getElementsByTagName('a')[0].parentNode,domtab.activeClass);
		var links=parentMenu.getElementsByTagName('a');
		for(i=0;i<links.length;i++){
			if(!links[i].getAttribute('href')){continue;}
			if(!/#/.test(links[i].getAttribute('href').toString())){continue;}
			id=links[i].href.match(/#(w.+)/)[1];
			if(id==loc){
				var cur=links[i].parentNode.parentNode;
				domtab.cssjs('add',links[i].parentNode,domtab.activeClass);
				break;
			}
		}
		domtab.changeTab(elm,1);
		elm.focus();
		cur.currentLink=links[i];
		cur.currentSection=loc;
	},
	showAll:function(e){
		document.getElementById(domtab.printID).parentNode.removeChild(document.getElementById(domtab.printID));
		var tempelm=document.getElementsByTagName('div');		
		for(var i=0;i<tempelm.length;i++){
			if(!domtab.cssjs('check',tempelm[i],domtab.tabClass)){continue;}
			var sec=tempelm[i].getElementsByTagName(domtab.contentElements);
			for(var j=0;j<sec.length;j++){
				sec[j].style.display='block';
			}
		}
		var tempelm=document.getElementsByTagName('ul');		
		for(i=0;i<tempelm.length;i++){
			if(!domtab.cssjs('check',tempelm[i],domtab.prevNextClass)){continue;}
			tempelm[i].parentNode.removeChild(tempelm[i]);
			i--;
		}
		domtab.cancelClick(e);
	},
	addPrevNext:function(menu){
		var temp;
		var sections=menu.getElementsByTagName(domtab.contentElements);
		for(var i=0;i<sections.length;i++){
			temp=domtab.createPrevNext();
			if(i==0){
				temp.removeChild(temp.getElementsByTagName('li')[0]);
			}
			if(i==sections.length-1){
				temp.removeChild(temp.getElementsByTagName('li')[1]);
			}
			temp.i=i; // h4xx0r!
			temp.menu=menu;
			sections[i].appendChild(temp);
		}
	},
	removeBackLinks:function(menu){
		var links=menu.getElementsByTagName('a');
		for(var i=0;i<links.length;i++){
			if(!domtab.backToLinks.test(links[i].href)){continue;}
			links[i].parentNode.removeChild(links[i]);
			i--;
		}
	},
	initTabMenu:function(menu){
		var id;
		var lists=menu.getElementsByTagName('ul');
		for(var i=0;i<lists.length;i++){
			if(domtab.cssjs('check',lists[i],domtab.listClass)){
				var thismenu=lists[i];
				break;
			}
		}
		if(!thismenu){return;}
		thismenu.currentSection='';
		thismenu.currentLink='';
		var links=thismenu.getElementsByTagName('a');
		for(i=0;i<links.length;i++){
			if(!/#/.test(links[i].getAttribute('href').toString())){continue;}
			id=links[i].href.match(/#(w.+)/)[1];
			if(document.getElementById(id)){
				domtab.addEvent(links[i],'click',domtab.showTab,false);
				links[i].onclick=function(){return false;} // safari hack
				domtab.changeTab(document.getElementById(id),0);
			}
		}
		id=links[0].href.match(/#(w.+)/)[1];
		if(document.getElementById(id)){
			domtab.changeTab(document.getElementById(id),1);
			thismenu.currentSection=id;
			thismenu.currentLink=links[0];
			domtab.cssjs('add',links[0].parentNode,domtab.activeClass);
		}
	},
	createPrevNext:function(){
		// this would be so much easier with innerHTML, darn you standards fetish!
		var temp=document.createElement('ul');
		temp.className=domtab.prevNextClass;
		temp.appendChild(document.createElement('li'));
		temp.getElementsByTagName('li')[0].appendChild(document.createElement('a'));
		temp.getElementsByTagName('a')[0].setAttribute('href','#');
		temp.getElementsByTagName('a')[0].innerHTML=domtab.prevLabel;
		temp.getElementsByTagName('li')[0].className=domtab.prevClass;
		temp.appendChild(document.createElement('li'));
		temp.getElementsByTagName('li')[1].appendChild(document.createElement('a'));
		temp.getElementsByTagName('a')[1].setAttribute('href','#');
		temp.getElementsByTagName('a')[1].innerHTML=domtab.nextLabel;
		temp.getElementsByTagName('li')[1].className=domtab.nextClass;
		domtab.addEvent(temp.getElementsByTagName('a')[0],'click',domtab.navTabs,false);
		domtab.addEvent(temp.getElementsByTagName('a')[1],'click',domtab.navTabs,false);
		// safari fix
		temp.getElementsByTagName('a')[0].onclick=function(){return false;}
		temp.getElementsByTagName('a')[1].onclick=function(){return false;}
		return temp;
	},
	navTabs:function(e){
		var li=domtab.getTarget(e);
		var menu=li.parentNode.parentNode.menu;
		var count=li.parentNode.parentNode.i;
		var section=menu.getElementsByTagName(domtab.contentElements);
		var links=menu.getElementsByTagName('a');
		var othercount=(li.parentNode.className==domtab.prevClass)?count-1:count+1;
		section[count].style.display='none';
		domtab.cssjs('remove',links[count].parentNode,domtab.activeClass);
		section[othercount].style.display='block';
		domtab.cssjs('add',links[othercount].parentNode,domtab.activeClass);
		var parent=links[count].parentNode.parentNode;
		parent.currentLink=links[othercount];
		parent.currentSection=links[othercount].href.match(/#(w.+)/)[1];
		domtab.cancelClick(e);
	},
	changeTab:function(elm,state){
		do{
			elm=elm.parentNode;
		} while(elm.nodeName.toLowerCase()!=domtab.contentElements)
		elm.style.display=state==0?'none':'block';
	},
	showTab:function(e){
		var o=domtab.getTarget(e);
		if(o.parentNode.parentNode.currentSection!=''){
			domtab.changeTab(document.getElementById(o.parentNode.parentNode.currentSection),0);
			domtab.cssjs('remove',o.parentNode.parentNode.currentLink.parentNode,domtab.activeClass);
		}
		var id=o.href.match(/#(w.+)/)[1];
		o.parentNode.parentNode.currentSection=id;
		o.parentNode.parentNode.currentLink=o;
		domtab.cssjs('add',o.parentNode,domtab.activeClass);
		domtab.changeTab(document.getElementById(id),1);
		document.getElementById(id).focus();
		domtab.cancelClick(e);
	},
/* helper methods */
	getTarget:function(e){
		var target = window.event ? window.event.srcElement : e ? e.target : null;
		if (!target){return false;}
		if (target.nodeName.toLowerCase() != 'a'){target = target.parentNode;}
		return target;
	},
	cancelClick:function(e){
		if (window.event){
			window.event.cancelBubble = true;
			window.event.returnValue = false;
			return;
		}
		if (e){
			e.stopPropagation();
			e.preventDefault();
		}
	},
	addEvent: function(elm, evType, fn, useCapture){
		if (elm.addEventListener) 
		{
			elm.addEventListener(evType, fn, useCapture);
			return true;
		} else if (elm.attachEvent) {
			var r = elm.attachEvent('on' + evType, fn);
			return r;
		} else {
			elm['on' + evType] = fn;
		}
	},
	cssjs:function(a,o,c1,c2){
		switch (a){
			case 'swap':
				o.className=!domtab.cssjs('check',o,c1)?o.className.replace(c2,c1):o.className.replace(c1,c2);
			break;
			case 'add':
				if(!domtab.cssjs('check',o,c1)){o.className+=o.className?' '+c1:c1;}
			break;
			case 'remove':
				var rep=o.className.match(' '+c1)?' '+c1:c1;
				o.className=o.className.replace(rep,'');
			break;
			case 'check':
				var found=false;
				var temparray=o.className.split(' ');
				for(var i=0;i<temparray.length;i++){
					if(temparray[i]==c1){found=true;}
				}
				return found;
			break;
		}
	}
}
domtab.addEvent(window, 'load', domtab.init, false);

示例代码:

 
<style type="text/css">
<!--
body {
	margin:0;
	padding:10px 5px;
	font-size:12px;
	font-family:verdana,arial,sans-serif,"宋体";
}
#warp {
	width:600px;
	margin:0 auto;
}
 
/* TAB样式 开始 */
ul.domtabs {
	list-style: none;
	font-size: 0.9em;
	border-bottom: 1px solid #D55E12;
	margin: 0 0 20px 0;
	padding: 0 30px 2px 0;
	text-align: right;
}
ul.domtabs li {
	display: inline;
	margin: 0;
}
ul.domtabs a:link,
ul.domtabs a:visited,
ul.domtabs a:active,
ul.domtabs a:hover {
	text-decoration: none;
	padding: 2px 5px 4px 5px;
	position: relative;
	bottom: 2px;
	color: #EA8544;
}
ul.domtabs li.active a:link,
ul.domtabs li.active a:visited,
ul.domtabs li.active a:active,
ul.domtabs li.active a:hover {
	background:#fff;
	padding: 2px 10px 4px 10px;
	border: 1px solid #D55E12;
	border-bottom: 1px solid #fff;
	position: relative;
	bottom: 2px;
	color: #D55E12;
	font-weight:bold;
}
ul.domtabs a:hover {
	text-decoration: underline;
	color: #D55E12;
}
ul.domtabs li.active a:hover {
	text-decoration: none;
}
 
/* 前后跳转 */
ul.prevnext {
	list-style-type: none;
	margin: 0;
	padding: .5em 0;
	border-top: 1px solid #D55E12;
}
 
ul.prevnext li a {
	display: block;
	width: 6em;
	color: #FFF;
	background-color: #D55E12;
	padding: 2px 0;
	text-align: center;
	text-decoration: none;
	font:12px bold "verdana";
}
 
ul.prevnext li a:hover {
	color: #FFF;
	background-color: #EA8544;
}
 
ul.prevnext .prev { float: left; }
ul.prevnext .next { float: right; }
 
h2.title {color:#D55E12;}
-->
</style>
 
<script type="text/javascript" src="js/domtab.js"></script>
 
<div id="warp">
 
	<div class="domtab doprevnext">
 
		<ul class="domtabs">
			<li><a href="#tab1">PHP/MySQL</a></li>
			<li><a href="#tab2">(X)HTML/CSS</a></li>
			<li><a href="#tab3">Javascript</a></li>
			<li><a href="#tab4">Ajax</a></li>
		</ul>
 
		<h2 class="title">Codebit.cn - 聚合小段精华代码</h2>
 
		<!-- TAB 1 -->
		<div>
 
			<h2><a name="tab1" id="tab1">PHP</a></h2>
			<p>PHP(“PHP: Hypertext Preprocessor”,超文本预处理器的字母缩写)是一种被广泛应用的开放源代码的多用途脚本语言,它可嵌入到 HTML中,尤其适合 web 开发。 </p>
 
			<h2><a name="mysql">MySQL</a></h2>
			<p>MySQL是最流行的开放源码SQL数据库管理系统,它是由MySQL AB公司开发、发布并支持的。MySQL AB是由多名MySQL开发人创办的一家商业公司。它是一家第二代开放源码公司,结合了开放源码价值取向、方法和成功的商业模型。</p>
 
			<p><a href="#top">back to menu</a></p>
 
		</div>
 
		<!-- TAB 2 -->
		<div>
 
			<h2><a name="tab2" id="tab2">(X)HTML</a></h2>
			<p>HTML语言是我们建立网页的工具,从它出现发展到现在,规范不断完善,功能越来越强。但是依然有缺陷和不足,人们仍在不断的改进它,使它更加便于控制和有弹性,以适应网络上日新月异的应用需求。2000年底,国际W3C(World Wide Web Consortium)组织公布发行了XHTML 1.0版本。</p>
 
			<p>XHTML 1.0是一种在HTML 4.0基础上优化和改进的的新语言,目的是基于XML应用。XHTML是一种增强了的HTML,它的可扩展性和灵活性将适应未来网络应用更多的需求。</p>
 
			<h2><a name="css">CSS</a></h2>
			<p>CSS 是 Cascading Style Sheet 的缩写。译作「层叠样式表单」。是用于(增强)控制网页样式并允许将样式信息与网页内容分离的一种标记性语言。</p>
 
			<p><a href="#top">back to menu</a></p>
 
		</div>
 
		<!-- TAB 3 -->
		<div>
 
			<h2><a name="tab3" id="tab3">Javascript</a></h2>
			<p>JavaScript 是一种新的描述语言,此一语言可以被嵌入 HTML 的文件之中。透过 JavaScript 可以做到回应使用者的需求事件 (如: form 的输入) 而不用任何的网路来回传输资料,所以当一位使用者输入一项资料时,它不用经过传给伺服端 (server)处理,再传回来的过程,而直接可以被客户端 (client) 的应用程式所处理。</p>
 
			<p><a href="#top">back to menu</a></p>
 
		</div>
 
		<!-- TAB 4 -->
		<div>
 
			<h2><a name="tab4" id="tab4">Ajax</a></h2>
			<p>AJAX (Asynchronous JavaScript and XML, 异步 JavaScript 及 XML 技术) 是个新词,但内涵是两个存在已有一段时间的 JavaScript 功能。这两种功能以往一直被忽略,在 Gmail、Google suggest 及  Google Maps 出现后才一举成名天下知。</p>
 
			<p>这两个 JavaScript 功能 是:
				<ul>
					<li>在不重新读取页面的情况下对伺服器送出要求(request)</li>
					<li>解析、使用 XML 文件</li>
				</ul>
			</p>
 
			<p><a href="#top">back to menu</a></p>
 
		</div>
 
	</div>
 
</div>

DOMTab 的页面样式完全由 css 控制,你可以通过在样式为 domtab 的 DIV 上添加一个 doprevnext 样式来生成前后跳转链接:

 
<ul class="prevnext">
	<li class="prev"><a href="#">previous</a></li>
	<li class="next"><a href="#">next</a></li>
</ul>

官方网站:
http://onlinetools.org/tools/domtabdata/

用背景图实现的 tab 标签页导航菜单效果

本文介绍的是一个非常不错的CSS tab 标签页导航菜单效果,代码简洁,兼容各种浏览器,最关键的是:通过学习实例里面的思路,我们很容易做出各种漂亮的 tab 效果,希望对初学者有帮助!

先看看抓图:

用背景图实现的 tab 标签页导航菜单效果 – 示例

 
<style type="text/css">
<!--
body {
	margin:0;
	padding:0;
	font: bold 11px/1.5em Verdana;
}
img {
	border: none;
}
 
/*- Menu Tabs 1--------------------------- */
#tabs1 {
	float:left;
	width:100%;
	background:#F4F7FB;
	font-size:93%;
	line-height:normal;
	border-bottom:1px solid #BCD2E6;
}
#tabs1 ul {
	margin:0;
	padding:10px 10px 0 50px;
	list-style:none;
}
#tabs1 li {
	display:inline;
	margin:0;
	padding:0;
}
#tabs1 a {
	float:left;
	background:url("tableft1.gif") no-repeat left top;
	margin:0;
	padding:0 0 0 4px;
	text-decoration:none;
}
#tabs1 a span {
	float:left;
	display:block;
	background:url("tabright1.gif") no-repeat right top;
	padding:5px 15px 4px 6px;
	color:#627EB7;
}
/* Commented Backslash Hack hides rule from IE5-Mac */
#tabs1 a span {float:none;}
/* End IE5-Mac hack */
#tabs a:hover span {
	color:#627EB7;
}
#tabs1 a:hover {
	background-position:0% -42px;
}
#tabs1 a:hover span {
	background-position:100% -42px;
}
#tabs1 #current a {
	background-position:0% -42px;
}
#tabs1 #current a span {
	background-position:100% -42px;
}
-->
</style>
 
<div id="tabs1">
	<ul>
		<li id="current"><a href="Home.html"><span>Home</span></a></li>
		<li><a href="Products.html"><span>Products</span></a></li>
		<li><a href="Services.html"><span>Services</span></a></li>
		<li><a href="Support.html"><span>Support</span></a></li>
		<li><a href="Order.html"><span>Order</span></a></li>
		<li><a href="News.html"><span>News</span></a></li>
		<li><a href="About.html"><span>About</span></a></li>
	</ul>
</div>

背景图片:

代码简洁,又兼容各种浏览器,仔细读读代码,相信会有很大收获!如果您原创或者收集到更漂亮的效果,记得共享哟!

一个效果不错的 TAB 样式

本文介绍一种将 <ul> 和 <li> 修饰成 TAB 风格的 CSS 样式。

先看看最终效果:

css tab

一个效果不错的 TAB 样式 – 示例

现在我们可以结合效果来看看代码。

先看看 CSS 部分 :

 
<style type="text/css">

body {
	font-family:verdana,arial,sans-serif,"宋体";
	font-size:12px;
	margin:0px;
	padding:0px;
	background:#aaa;
}

a {
	color: #003499; 
	text-decoration: none;
}

a:hover {
	color: #000000; 
	text-decoration: underline;
}

#tabnav {
	background:#d5d5d5;
	border-bottom:1px solid #333;
	padding-bottom:3px;
}

#tabnav ul {
	padding:15px 0px 5px 0px;
	margin:5px 0px 5px 0px;
	list-style:none;
	background:#f1f1f1;
	border-bottom:1px solid #999;
}

#tabnav ul li {
	display:inline;
	margin-left:10px;
}

#tabnav ul li a {
	background:#fff;	
	padding:5px 10px 5px 10px;
	border:1px solid #999;
}

#tabnav ul li a:hover {
	background:#ccc;	
}

#tabnav ul li a.here {
	background:#d5d5d5;
	padding:5px 10px 5px 10px;
	border-top:1px solid #999;
	border-left:1px solid #999;
	border-right:1px solid #999;
	border-bottom:1px solid #d5d5d5;
}

#tabnav ul li a.here:hover {
	background:#d5d5d5;
}
	
</style>

代码中首先定义了整个文档的字体、文字大小及背景等信息,还定义了默认的链接样式。关键部分从 #tabnav 开始, #tabnav 就是要定义的 <ul> 的父元素,然后逐层定义 <li> <a> 等样式。

参照效果图我们可以看到:#tabnav ul li a.here 定义的是当前选中的链接样式。

对照着 (X)HTML 看看:

 
<div id="tabnav">
<ul>
	<li><a href="#">首页</a></li>
	<li><a href="#" class="here">技术文章</a></li>
	<li><a href="#">提交文章</a></li>
	<li><a href="#">联系我们</a></li>
</ul>
</div>

通过修改 CSS 我们可以很容易的改变整个 TAB 的显示风格。

CSS Beauty 风格的两列新闻显示样式

本文向您推荐的是 CSS Beauty 风格的两列新闻显示样式, 新闻是一般网站必不可少的功能, 而新闻列表的表现方式也是多姿多彩的, 本文介绍的是按两列显示的新闻列表方案, 同时还有一个 TAB 浏览的 Javascript 技巧和 FORM 元素的样式设计.

CSS Beauty 风格的两列新闻显示样式 – 示例

CSS 部分:

 
<style type="text/css">
<!--
body, td, div, p, span, textarea, select {
	font-size: 12px; font-family: verdana, arial, helvetica, sans-serif
}
a {
	color: #DCB20C; text-decoration: none; font-size: 12px;
}
a:hover {
	color: #CC9933; text-decoration: underline; font-size: 12px;
}

/* ClearFix */
.clearfix:after {
    content: "."; 
    display: block; 
    height: 0; 
    clear: both; 
    visibility: hidden;
}
.clearfix {display: inline-table;}

/* Hides from IE-mac */
.clearfix {height: 1%;}
.clearfix {display: block;}
/* End hide from IE-mac */


/* 公用 FORM 样式 */
input, textarea{
	background: #fff;
	border: 1px solid #83cde1;
	border-top: 3px solid #83cde1;
}
input:hover, textarea:hover {
	background: #F0FDE2;
	border-top: 3px solid #b1e77a
}
input:focus, textarea:focus {
	background: #FCFFEC;
	border-top: 3px solid #b1e77a
}
.submit { border: 0; width: auto; }
.submit:hover, .submit:active { border:0; }
.radio { background: none; border: 0; }


#news {
	margin:0;
	padding:0 15px 5px 10px;
	border-bottom: 1px dotted #BBE0EB;
}

/* TAB样式 开始 */
#news ul.domtabs {
	list-style: none;
	font-size: 0.9em;
	border-bottom: 1px dotted #BBDFED;
	margin: 0 0 20px 0;
	padding: 0 30px 2px 0;
	text-align: right;
}
#news ul.domtabs li {
	display: inline;
	margin: 0;
}
#news ul.domtabs a:link,
#news ul.domtabs a:visited,
#news ul.domtabs a:active,
#news ul.domtabs a:hover {
	text-decoration: none;
	padding: 2px 5px 4px 5px;
	position: relative;
	bottom: 0;
	color: #89C7D9;
}
#news ul.domtabs li.active a:link,
#news ul.domtabs li.active a:visited,
#news ul.domtabs li.active a:active,
#news ul.domtabs li.active a:hover {
	background:#fff;
	padding: 2px 10px 4px 10px;
	border: 1px dotted #BBDFED;
	border-bottom: 1px solid #fff;
	position: relative;
	bottom: 0;
	color: #418FA5;
}
#news ul.domtabs a:hover {
	text-decoration: underline;
}
#news ul.domtabs li.active a:hover {
	text-decoration: none;
}


/* 新闻列表样式 开始 */
#newswrap {
	margin:0;
}
#news-left, #news-right {
	float: right;
	width: 48%;
	max-width: 330px;
}
#news .more {
	clear: both;
	margin:0;
	padding: 0 15px 0 0;
	font-size: 0.85em;
	text-align: right;
	line-height: 1em;
}
#news .more img {
	vertical-align: bottom;
	border: 0;
	margin: 0 0 0 5px;
}
#news-right p, #news-left p {
	font-size: 0.85em;
	padding: 0 5px 0 0;
	margin: 0 0 0 12px;
	color: #4896AC;
}
#news-right p a, #news-left p a {
	font-weight: bold;
	display:block;
}
#news-right p a.continue, #news-left p a.continue {
	font-weight: normal;
}
#news p.author {
	color: #83cde1;
	border: 0;
	padding: 0 0 5px 0;
	margin: 0 10px 10px 12px;
	border-bottom: 1px dotted #BBE0EB;
}
#news p.author a {
	color: #86d734;
	font-weight: normal;
	display:inline;
	font-size: 0.85em;
}
#news p.author a:hover {
	text-decoration: underline;
}
#news p.author:hover {
	background: none;
}


/* FORM 表单样式 开始 */
#news #form {
	display: none;
}
#news form {
	float: right;
	margin: 0;
	padding: 0;
	background: #fff;
	font-size: 0.9em;
	width: 85%;
}
#news form p {
	padding: 0 0 0 20px;
	float: left;
	margin: 0;
	width: 180px;
	color: #4896AC;
}
#news form p.note {
	margin: 0 0 20px 0;
}
#news fieldset {
	border: 0;
}
#news legend {
	display: none;
}
#news label {
	display: block;
}
#news input {
	margin: 0 0 10px 0;
	display: block;
	width: 150px;
}
#news textarea {
	margin: 0;
	width: 150px;
	height: 100px;
}
#news .submit {
	width: auto;
	border: 0;
}

-->
</style>

HTML 部分:

 
<div id="news" class="domtab clearfix">

	<ul class="domtabs">
		<li class="active"><a href="#news-right">Current News</a></li>
		<li><a href="#submit-news">Submit News</a></li>
	</ul>

	<div style="display: block;" id="newswrap">	
	
		<div id="news-right">
			
			<p><a href="http://www.sitepoint.com/article/accessibility-techniques">Advanced Accessibility Techniques.</a> Techniques you can implement to achieve advanced accessibility beyond the W3C guidelines.</p>
			<p class="author">Posted by <a href="http://www.cssbeauty.com/">Alex Giron</a> on Aug 07 at 07:24 AM</p>
						
			<p><a href="http://www.brothercake.com/site/resources/reference/3d/">Dynamic 3D with CSS and the DOM.</a>Underground - A 3D dungeon environment built using Tantek's technique of creating shapes out of the interaction of CSS borders.</p>
			<p class="author">Posted by <a href="http://www.cssbeauty.com/">Alex Giron</a> on Aug 04 at 08:38 AM</p>
						
			<p><a href="http://www.brothercake.com/site/resources/scripts/dbx/">Docking boxes (dbx).</a> Adds animated drag 'n' drop, snap-to-grid, and show/hide-contents functionality to any group of elements.</p>
			<p class="author">Posted by <a href="http://www.cssbeauty.com/">Alex Giron</a> on Aug 03 at 11:22 AM</p>
						
			<p><a href="http://www.useit.com/alertbox/screen_resolution.html">Screen Resolution and Page Layout.</a> Optimize Web pages for 1024x768, but use a liquid layout that stretches well for any resolution, from 800x600 to 1280x1024.</p>
			<p class="author">Posted by <a href="http://www.cssbeauty.com/">Alex Giron</a> on Aug 02 at 07:50 AM</p>
						
			<p><a href="http://accessites.org/gbcms_xml/news_page.php?id=19">Visual Vs. Structural.</a> Does the choice of approach — visual vs structural — have any impact on the accessibility or usability of a site?</p>
			<p class="author">Posted by <a href="http://www.cssbeauty.com/">Alex Giron</a> on Aug 02 at 07:47 AM</p>
			
		</div>

		<div id="news-left">
			
			<p><a href="http://www.456bereastreet.com/archive/200608/google_valid_and_strict/">Google valid and strict.</a>Roger Johansson debunks the myth that Google has deprecated code tosave on bandwidth. He speculates why they still use old markup.</p>
			<p class="author">Posted by <a href="http://sonspring.com/">Nathan Smith</a> on Aug 15 at 01:37 AM</p>
						
			<p><a href="http://techfoolery.com/archives/2006/08/11/2021/">Animated Page Scroller</a>. An elegant JavaScript solution for page navigation</p>
			<p class="author">Posted by <a href="http://dustindiaz.com/">Dustin Diaz</a> on Aug 15 at 12:43 AM</p>
						
			<p><a href="http://www.aptana.com/" title="JavaScript Love Maker">Aptana Web IDE</a>. A robust, JavaScript-focused IDE for building dynamic web applications.</p>
			<p class="author">Posted by <a href="http://dustindiaz.com/">Dustin Diaz</a> on Aug 15 at 12:28 AM</p>
						
			<p><a href="http://www.flickrshow.com/">Flickrshow.</a> Provides you with the simplest way of displaying your Flickr photosets on your own website with the use of some javascript.</p>
			<p class="author">Posted by <a href="http://www.cssbeauty.com/">Alex Giron</a> on Aug 10 at 11:06 AM</p>
						
			<p><a href="http://jquery.com/demo/thickbox/">ThickBox 2.0.</a> Version 2 of the JQuery based photo slideshow script, new features include iFrame support, multi-picture slideshows and more.</p>
			<p class="author">Posted by <a href="http://www.cssbeauty.com/">Alex Giron</a> on Aug 09 at 09:31 AM</p>
			
		</div>

		<p class="more"><a href="http://www.cssbeauty.com/news/">News Archive</a> <a href="http://www.cssbeauty.com/rss/news/"><img src="rss.gif" alt="RSS Feed" /></a></p>

	</div>

	<div id="form">
		<form action="/news/submit/snews.php" method="post" id="submit-news">
			<fieldset>
				<legend>Submit News</legend>

				<p>
				<label for="title">Title:</label>

				<input type="text" tabindex="1" name="n-title" id="title" />

				<label for="url">News URL:</label>
				<input type="text" tabindex="2" name="n-url" id="url" />

				<label for="description">News Description:</label>
				<textarea tabindex="3" name="n-description" id="description" rows="5" cols="15"></textarea>
				<small>Max 120 characters</small>

				</p>

				<p class="note"><strong>Note:</strong> Your submission will be placed on queue pending review, if accepted your news item will show up in the next few hours.</p>
					
				<p>
				<label for="name">Your Name:</label>
				<input type="text" tabindex="4" name="s-name" id="name" />

				<label for="email">Your email:</label>

				<input type="text" tabindex="5" name="s-email" id="email" />

				<label for="yurl">Your Website:</label>
				<input type="text" tabindex="6" name="s-url" id="yurl" />
					
				<input class="submit" type="image" src="submit.gif" alt="submit" tabindex="7" />
				</p>
			</fieldset>
		</form>
	</div>

</div>

本文只是摘录原网站的部分代码, 目的是整理其实现技巧, 如果您有其他目的或用途, 请联系原网站.