JavaScript实现tab效果图

这个示例展示了如何使用JavaScript和HTML/CSS创建一个动态Tab效果。代码中定义了不同Tab内容,当用户鼠标悬停在Tab按钮上时,会显示相应的内容。包括商品分类如疯狂抢购、热卖商品等,每个Tab下展示多张商品图片及其描述和价格。
摘要由CSDN通过智能技术生成

图片地址:http://download.csdn.net/detail/richard_jason/9669782

效果图:



示例代码:

<!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>Tab效果</title>
<style type="text/css">
<!--
*{margin:0;padding:0;border:none;text-shadow:1px 0 0 #ddd;}
a{text-decoration:none;}
img{border:0;}
.container{width:890px; overflow:hidden;font-size:14px; border:1px solid #ddd; border-top:2px solid #c00; margin:40px auto;}
#tabbox{width:895px; height:38px; overflow:hidden; background:#ddd; }
#tabbox span{font-family:"微软雅黑"; font-weight:bold;color:#333; background:#F4F5F5; display:block;width:178px; height:37px; line-height:37px; text-align:center; float:left; margin-right:1px; cursor:pointer;_display:inline;}
#tabbox span.curr{ background:#fff; border-bottom:1px solid #fff; color:#c00;}


#cont div{width:100%; overflow:hidden; display:none;}
#cont div dl{width:130px; margin:20px 24px; float:left;_display:inline;}
#cont div dl dt{margin-bottom:10px;}
#cont div dl dd img{width:130px; height:130px;}
#cont div dl dd.des{width:100%; height:32px; line-height:16px; overflow:hidden; font-size:12px;}
#cont div dl dd.des a{color:#333;}
#cont div dl dd.price{width:100%; height:16px; line-height:16px;font-size:12px;color:#999;}
#cont div dl dd.price span{font-weight:bold; color:#c00;}
#cont div.curr{display:block;}
-->
</style>
<script type="text/javascript">
<!--
function setCurr(index){
var arrSpan=document.getElementById("tabbox").getElementsByTagName("span");
for(var i=0;i<arrSpan.length;i++){arrSpan[i].className="";arrSpan[index].className="curr";}
var arrDiv=document.getElementById("cont").getElementsByTagName("div");
for(var j=0;j<arrDiv.length;j++){arrDiv[j].className="";arrDiv[index].className="curr";}
}
//-->
</script>


</head>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值