簡單js實現豎行tab切換

來源:互聯網
上載者:User

標籤:tab切換   des   http   title   hit   radius   char   parent   ast   

<!DOCTYPE >
<html lang="ru">
<head>
<title>簡單js實現豎行tab切換</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<style type="text/css">
*{
margin:0;padding:0;
 -webkit-box-sizing: border-box;
 -moz-box-sizing: border-box;
   box-sizing: border-box;
}
.container{
margin:0 auto;
width:500px;
overflow:hidden;
background:beige;
}
li{
border-top:1px solid lightgrey;
border-left:1px solid lightgrey;
border-right:1px solid lightgrey;
height:35px;
line-height:35px;
list-style:none;
text-align:center;
width:100px;
}
li  a{width:100px;  height: 36px;  display: block;}
li:last-child{
height:159px;border-right:1px solid lightgrey;
border-bottom:1px solid lightgrey;
}
li.active {
border-right:1px solid white;background:white;
}
li.normal {
border-right:1px solid white;background:red;
}
#tab_content{
float:right;
width:400px;
*width:394px;
background:white;
height:300px;
overflow:hidden;
border-top:1px solid lightgrey;
border-right:1px solid lightgrey;
border-bottom:1px solid lightgrey;
border-left:0px solid lightgrey;
}
#tab_content .content{
 padding: 15px;
 -moz-border-radius: 5px;
height:300px;
}
</style>
</head>
<body>
<div class=‘container‘ >
 <div id="tab_content">
 <div id="a" class="content">
111111111111111111111111111
 </div>
 <div id="b" class="content">
222222222222222222222222222
 </div>
 <div id="c" class="content">
333333333333333333333333333
 </div>
 <div id="d" class="content">
444444444444444444444444444
 </div>
 <div id="e" class="content">
     555555555555555555555555
 </div>
</div>
<div >
<ul id=‘tabnav‘><li ><a href="#a" >1</a></li>
<li class=‘active‘><a href="#b" >2</a></li>
<li><a href="#c" >3</a></li>
<li><a href="#d" >4</a></li>
<li ><a href="#e" >5</a></li>
</ul>
</div>
</div>
<script type="text/javascript">
function changeStyle(){
 this.onclick=function(){
 var list=this.parentNode.childNodes;
 for(var i=0;i<list.length;i++){
  if(1==list[i].nodeType && ‘active‘==list[i].className){
    list[i].className="";
  }
 }
 this.className=‘active‘;
 }
}
 var tabs=document.getElementById(‘tabnav‘).childNodes;
 for(var i=0;i<tabs.length;i++){
 if(1==tabs[i].nodeType){
  changeStyle.call(tabs[i]);
 }
}
</script>
</body>
</html>

簡單js實現豎行tab切換

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.