tab------左右布局

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style type="text/css">
*{margin: 0;padding: 0;}
#box{width: 880px;height: 480px;border: 1px solid #ddd;margin: 100px auto;}
#box .list{width: 180px;border-right:1px solid #ddd ;height: 480px;float: left;}
#box .list li{height: 45px;border-bottom:1px solid #ddd ;list-style: none;line-height: 45px;font-size: 16px;text-align: center;}
#box .con{width: 698px;height: 400px;background: #ccc;float: left;overflow: hidden;}
#box .on{background: #ccc;}

#box .con div{
width: 695px;height: 480px;font-size: 14px;text-align: center;
}
#box .con div:nth-child(1){
background: palegreen;
}
#box .con div:nth-child(2){
background:orange;
}
#box .con div:nth-child(3){
background:palevioletred;
}
#box .con div:nth-child(4){
background:blueviolet;
}
#box .con div:nth-child(5){
background:brown ;
}
</style>
</head>
<body>
<div id="box">
<div class="list">
<ul>
<li class="on">哈哈</li>
<li>嘻嘻</li>
<li>喵喵</li>
<li>某某</li>
<li>喳喳</li>
</ul>
</div>
<div class="con">
<div>哈哈啊哈哈</div>
<div>嘻嘻嘻嘻嘻嘻嘻</div>
<div>喵喵密密麻麻</div>
<div>某某某某某某</div>
<div>扎扎扎扎咋呼咋哈</div>
</div>
</div>

<script type="text/javascript" src="js/jquery-3.1.0.min.js" ></script>
<script type="text/javascript">
$(function(){
var $li = $(".list li");
var $conDiv = $(".con div");

$li.mouseover(function(){
var $index = $(this).index();
$(this).addClass("on").siblings().removeClass("on");
$conDiv.eq($index).show().siblings().hide();
});
})
</script>
</body>
</html>

posted @ 2016-09-19 21:37  江山一族  阅读(730)  评论(0编辑  收藏  举报