<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
<title>1.实战明星相册</title>
<style type="text/css">
.box {
width: 500px;
height: 700px;
background-color: #efefef;
border: 1px solid lightgray;
margin: 20px auto;
text-align: center;
color: #636363;
box-shadow: 2px 2px 2px #999;
}
.box ul {
margin: 0;
padding: 0;
overflow: hidden;
}
.box ul li {
float: left;
list-style-type: none;
margin-left: 20px;
background-color: skyblue;
}
.box ul li a {
display: block;
width: 100px;
height: 40px;
line-height: 40px;
color: white;
text-decoration: none;
}
.box ul li a:hover {
background-color: coral;
font-size: 1.1em;
}
.box .pic {
width: 450px;
height: 470px;
border: 1px solid lightgray;
line-height: 1px;
margin: auto;
margin-top: 50px;
}
.box .pic img {
width: 100%;
height: 470px;
}
</style>
</head>
<body>
<div class="box">
<h2>明星相册</h2>
<ul>
<li><a href="images1/zly.jpg" title="《楚乔传》、《花千骨》..." onclick="changePic(this);return false;">赵丽颖</a></li>
<li><a href="images1/gyy.jpg" title="《倚天屠龙记》、《爱无悔》..." onclick="changePic(this);return false;">高圆圆</a></li>
<li><a href="images1/sl.jpg" title="《那年花开月正圆》、《玉观音》..." onclick="changePic(this);return false;">孙俪</a></li>
<li><a href="images1/fbb.jpg" title="《还珠格格》、《我不是潘金莲》..." onclick="changePic(this);return false;">范冰冰</a></li>
</ul>
<div class="pic">
<img src="images1/zwt.png" alt="" id="img">
</div>
<p id="info"></p>
</div>
<script type="text/javascript">
function changePic(pic){
// 获取一个明星图片和简介
var picUrl = pic.href
var picInfo = pic.title
// 获取到要被替换掉的对象
var img = document.getElementById('img')
var p = document.getElementById('info')
// 将对应的占位符对象进行替换
img.src = picUrl
p.innerHTML = picInfo
}
</script>
</body>
</html>