实例:
代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="http://code.jquery.com/jquery-1.4.1.min.js"></script>
<style>
body{
padding:0;
margin: 0;
}
.box{
width:1200px;
height: 400px;
border: 1px solid #000;
margin:200px auto;
background: url("https://edu-image.nosdn.127.net/c4f06635e49848ef8325b756d1ad7149.jpg?imageView&quality=100&thumbnail=1205y400") no-repeat;
position: relative;
}
.uls{
height: 100%;
width: 200px;
margin:0;
padding:0;
list-style:none ;
display: inline-block;
float: left;
background:rgba(128,132,123,0.8);
}
.uls li{
height:50px;
line-height:50px;
text-align: center;
padding:0 20px;
}
.uls li span{
width:100%;
display: block;
border-bottom:1px solid #babac6;
}
.uls li:last-child span{
border-bottom:none;
}
.uls li:hover{
background: rgba(251, 255, 243, 0.8);
}
.box .content{
width:1000px;
height:400px;
position: absolute;
top:0;
left:200px;
display: none;
}
.box .content1{
background:red;
}
.box .content2{
background:yellow;
}
.box .content3{
background:blue;
}
.box .content4{
background:green;
}
.box .content5{
background:skyblue;
}
</style>
</head>
<body>
<div class="box">
<ul class="uls">
<li>
<span>1</span>
<div class="content content1">1</div>
</li>
<li>
<span>2</span>
<div class="content content2">2</div>
</li>
<li>
<span>3</span>
<div class="content content3">3</div>
</li>
<li>
<span>4</span>
<div class="content content4">4</div>
</li>
<li>
<span>5</span>
<div class="content content5">5</div>
</li>
</ul>
</div>
<script>
$(".uls li").hover(
function(){
$(".content").eq($(this).index()).css({"display":"inline-block"});
},
function(){
$(".content").eq($(this).index()).css({"display":"none"});
}
)
</script>
</body>
</html>
效果: