<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
body{
height:500px
background: linear-gradient(#A6CADE,#F8C6F8) no-repeat
}
ul,li,div {
padding:0margin:0
}
.container{
width: 500px
margin:0 auto
}
#tab-con div{
display: none
width:500px
height:282px
}
#tab-con div img{
width: 100%
height:100%
}
#tab-con div.active{
display: block
}
#tab-list ul li{
float:left
list-style: none
}
#tab-list ul li a{
display: block
width:70px
text-align: center
text-decoration: none
color:#000
background: #D6D6D1
}
#tab-list ul li.active a{
color:#fff
background:#f96302
}
</style>
</head>
<body>
<div class="container">
<div id="tab-con">
<div class="active"><img src="img/test1.jpg"></div>
<div><img src="img/test2.jpg"></div>
<div><img src="img/test3.jpg"></div>
<div>图片4</div>
<div>图片5</div>
<div>图片6</div>
<div>图片7</div>
</div>
<div id="tab-list">
<ul>
<li><a href="javascript:">首页</a></li>
<li><a href="javascript:">美食</a></li>
<li><a href="javascript:">交通</a></li>
<li><a href="javascript:">图片4</a></li>
<li><a href="javascript:">图片5</a></li>
<li><a href="javascript:">图片6</a></li>
<li><a href="javascript:">图片7</a></li>
</ul>
</div>
</div>
<script>
var tablist = document.getElementById('tab-list').getElementsByTagName('li')
var tabcon = document.getElementById('tab-con').getElementsByTagName('div')
for(var i = 0 i<tablist.length i++){
tablist[i].onclick = function(){
starttab(this)
}
}
function starttab(obj){
for(var i = 0 i<tablist.length i++){
if(tablist[i] == obj){
tablist[i].className = "active"
tabcon[i].className = "active"
}else{
tablist[i].className = ""
tabcon[i].className = ""
}
}
}
</script>
</body>
</html>