点击x,小广告盒子就隐藏起来(display:none实现)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
body{
height: 3000px;
background:grey;
}
#box{
width: 195px;
height: 250px;
background: white;
position:fixed;//相对于浏览器窗口进行定位
right: 0;
bottom: 0;
}
#pic a#closeBtn{
display: inline-block;
background: red no-repeat -120px -19px;
text-align: center;
text-decoration: none;
top:5px;
right: 5px;
width: 16px;
height: 16px;
position: absolute;//相对于第一个父元素进行定位
}
#pic a#closeBtn:hover{
/*background-position: -100px;-19px;*/
background:white;
}
.hide{
display: none;
}
</style>
<script type="text/javascript">
//function close(){ var obj=document.getElementById("closeBtn");obj.style.display="none";}
window.οnlοad=function(){
var tipbtn=document.getElementById("box");
var closebtn=document.getElementById("closeBtn");
closebtn.οnclick=function(){
tipbtn.className="hide";
}
}
//对比,第一种简单
</script>
</head>
<body>
<div id="box">
<div id="pic">
<a href="http://www.baidu.com"><img src="tanchuang.png"></a>
<a href="javascript:void(0);" id="closeBtn" >x</a>//οnclick="close()"
</div>
</div>
</body>
</html>