作业图:
代码:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style>
.box {
width: 322px;
position: fixed;
bottom: 0;
right: 0;
overflow: hidden;
}
span {
position: absolute;
top: 0;
right: 0;
width: 30px;
height: 20px;
cursor: pointer;
}
</style>
</head>
<body>
<div class="box" id="box">
<span id="closeButton"></span>
<div class="hd" id="headPart">
<img src="./img/t.jpg" alt=""/>
</div>
<div class="bd" id="bottomPart">
<img src="./img/b.jpg" alt=""/>
</div>
</div>
</body>
</html>
<script src="./jquery-1.12.4.min.js"></script>
<script>
$(function() {
// 1. 给关闭按钮注册事件 也就是span标签
$('#closeButton').on('click', function() {
// 2. 先让底部的盒子高度变成0
$('#bottomPart').animate({
height: 0
}, 500, function() {
// 3. 再让最大的盒子box宽度变成0
$('#box').animate({
width: 0
}, 500)
})
})
})
</script>
注意:class名称,js地址,图片地址