Moo.fx滑动效果选项卡

1. 样式定义 

body {
	color: #333;
	font-size: 11px;
	font-family: verdana;
}

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

a:hover {
	color: #DFE44F;
}

p {
	margin: 0;
	padding: 5px;
	line-height: 1.5em;
	text-align: justify;
	border: 1px solid #73A405;
}

#wrapper {
	width: 800px;
	margin: 0 auto;
}

.box {
	background: #fff;
}

.boxholder {
	clear: both;
	padding: 5px;
	background: #8DC70A;
}

.tab {
	float: left;
	height: 32px;
	width: 102px;
	margin: 0 1px 0 0;
	text-align: center;
	background: #8DC70A url(images/greentab.jpg) no-repeat;
}

.tabtxt {
	margin: 0;
	color: #fff;
	font-size: 12px;
	font-weight: bold;
	padding: 9px 0 0 0;
}

 

2. 引入 JS 脚本

<script type="text/javascript" src="scripts/prototype.lite.js"></script>
<script type="text/javascript" src="scripts/moo.fx.js"></script>
<script type="text/javascript" src="scripts/moo.fx.pack.js"></script>

 

3. 定义初始化函数

function init() {
	var stretchers = document.getElementsByClassName('box');
	var toggles = document.getElementsByClassName('tab');
	var myAccordion = new fx.Accordion(
		toggles, stretchers, {opacity: true, height: true, duration: 600}
	);
	//hash functions
	var found = false;
	toggles.each(function(h3, i){
		var div = Element.find(h3, 'nextSibling');
			if (window.location.href.indexOf(h3.title) > 0) {
				myAccordion.showThisHideOpen(div);
				found = true;
			}
		});
		if (!found) myAccordion.showThisHideOpen(stretchers[0]);
}

 

4. 定义 HTML 元素

<div id="wrapper">
	<div id="content">
		<div id="test" class="tab" title="first">
			<h3 class="tabtxt"><a href="#">first</a></h3>
		</div>
		<div class="tab">
			<h3 class="tabtxt" title="second"><a href="#">second</a></h3>
		</div>
		<div class="tab">
			<h3 class="tabtxt" title="third"><a href="#">third</a></h3>
		</div>
		<div class="tab">
			<h3 class="tabtxt" title="fourth"><a href="#">fourth</a></h3>
		</div>
		<div class="boxholder">
			<div class="box">
				<p><strong>The First Box</strong></p>
			</div>
			<div class="box">
				<p>
					<strong>The Second Box</strong>
				</p>
			</div>
			<div class="box">
				<p>
					<strong>The Third Box</strong>
				</p>
			</div>
			<div class="box">
				<p>
					<strong>The Fourth Box</strong>
					<br />
				</p>
			</div>
		</div>
	</div>
</div>

 

5. JS 函数调用

<script type="text/javascript">
	Element.cleanWhitespace('content');
	init();
</script>

 

6. 效果预览

 

7. Demo 下载

附件 demo,欢迎下载。

 

8. 探讨

不可否认,该选项卡的渐变滑动效果确实很靓,但是各个选项卡的选中和未选中状态均一样,这会给人一种难以区分的错觉,也许这是它的不足吧,又或者是本人尚未深入研究,暂时仍不知道如何设置或者修改。

如果大家知道,望不吝赐教。

 

 

-------------------------------------------------

Stay Hungry, Stay Foolish!

Afa

May 18th, 2010

-------------------------------------------------

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值