JS效果日记(四)
——关闭小广告
简单易懂上代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
* {
margin: 0;
padding: 0;
}
#box {
/* 因为图片大小是400x400所以盒子宽度有预留哦 */
width: 420px;
height: 400px;
position: relative;
}
#photo {
position: absolute;
right: 0;
}
#box span {
width: 18px;
height: 18px;
border: 1px solid #e0e0e0;
position: absolute;
text-align: center;
line-height: 18px;
color: #666;
cursor: pointer;
}
</style>
</head>
<body>
<div id="box">
<img src="img/1113.jpg" id="photo">
<span id="close">x</span>
</div>
<script>
var closespan = document.getElementById('close');
var photo = document.getElementById('photo');
closespan.onclick = function() {
box.style.display = 'none';
}
</script>
</body>
</html>
新手小白
还请求大佬多多指教