最简单的tab控件,纯html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml2/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<style type="text/css">
<!--
.tab{
padding: 0;
width: 100%;
border-bottom: 5px solid #D25A0B;
background: transparent;
voice-family: "/"}/"";
voice-family: inherit;
}

.tab ul{
margin:0;
margin-left: 10px; /*margin between first menu item and left browser edge*/
padding: 0;
list-style: none;
}

.tab li{
display: inline;
margin: 0 2px 0 0;
padding: 0;
text-transform:uppercase;
}

.tab a{
float: left;
display: block;
font: bold 11px Arial;
color: white;
text-decoration: none;
margin: 0 1px 0 0; /*Margin between each menu item*/
padding: 5px 10px;
background-color: black; /*Brown color theme*/
border-top: 1px solid white;
}

.tab a:hover{
/*background-color: #D25A0B;*/ /*Brown color theme*/
color: white;
}

.tab a.selected{ /*currently selected tab*/
background-color: #D25A0B; /*Brown color theme*/
color: white;
border-color: #D25A0B; /*Brown color theme*/
}

-->
</style>

<script language="javascript" type="text/javascript">
function fGoto(url)
{
   oFrame.location=url; //your url
  
   ClearElement();
   getsrcElement("A").style.backgroundColor = "#D25A0B";
 
}

function ClearElement()
{
   var list = document.getElementsByTagName("a");
   for (var i=0;i<list.length;i++)
   {  
     list[i].style.backgroundColor = ""; 
   }
}

function getsrcElement(oType)
{
    var o = event.srcElement;
    while (o.tagName != oType)
 {
    o = o.parentElement;
 }
    return o;
}
</script>

</head>

<body>
<div class="tab">
<ul id="ulTab">
<li><a href=# οnclick="fGoto('http://www.163.com')">tab1</a></li>
<li><a href=# οnclick="fGoto('http://www.sohu.com')">tab2</a></li>
<li><a href=# οnclick="fGoto('http://www.263.com')">tab3</a></li>
</ul>
</div>

<iframe frameborder="0" id="oFrame" scrolling="no" src="" style="text-align:left;height:248px;width: 100%"></iframe>

</body>
</html>

 

<!--tab控件有时候我们很需要,但是当我们去网找一个的时候,用起来总是那么的麻烦,要不就是买控件的,要不就是与我们所需要的有蛮大的差距.这个也是根据网上的代码稍加改造而来,其特点就是简单,简单,纯html.这样大家可以根据自己的需要再做进一步修改.-->

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值