<!DOCTYPE html>
<html>
<head ><lang="en"></lang>
<meta charset="UTF-8">
<title>实践题 - 选项卡</title>
<style type="text/css">
/* CSS样式制作 */
/**
cursor:pointer;手型光标
**/
*{margin:0;padding:0;font-size:14px;font-family:宋体;}
#d{
width:290px;height:150px;padding;10px;margin:20px;
}
#d ul{
list-style:none;display:block;line-height:30px;height:1px;
}
#d ul li {
float:left;width:60px;height:30px;line-height:30px;margin:0px 3px ;border:1px solid gray;border-bottom:none;text-align:center; cursor:pointer; display:inline-block;
}
#d ul li.on{
border-top:2px solid #f11;border-bottom:2px solid #fff;
}
#d div{
height:120px;line-height:25px;border:1px solid gray;border-top:2px solid #f11; padding:5px;margin-top:30px;
}
.hide{display:none;}
li:hover{background-color:#f60;}
</style>
<script type="text/javascript">
// JS实现选项卡切换
window.onload=function(){
var d=document.getElementById("d");
var li=document.getElementsByTagName("li");
var div=d.getElementsByTagName("div");
for(var i=0;i<li.length;i++){
li[i].index=i;
li[i].onclick=function(){
for(var n=0;n<li.length;n++){
li[n].className="";
div[n].className="hide";
}
this.className="on";
div[this.index].className="";
}
}
}
</script>
</head>
<body>
<!-- HTML页面布局 -->
<div id="d">
<ul>
<li class="on">房产</li>
<li>家居</li>
<li>二手房</li>
</ul>
<div>
275万购昌平邻铁三居 总价20万买一居<br/>
200万内购五环三居 140万安家东三环<br/>
北京首现零首付楼盘 53万购东5环50平<br/>
京楼盘直降5000 中信府 公园楼王现房</div>
<div class="hide">
40平出租屋大改造 美少女的混搭小窝<br/>
经典清新简欧爱家 90平老房焕发新生<br/>
新中式的酷色温情 66平撞色活泼家居<br/>
瓷砖就像选好老婆 卫生间烟道的设计</div>
<div class="hide">
通州豪华3居260万 二环稀缺2居250w甩<br/>
西3环通透2居290万 130万2居限量抢购<br/>
黄城根小学学区仅260万 121平70万抛!<br/>
独家别墅280万 苏州桥2居优惠价248万</div>
</div>
</body>
</html>