仿QQ新闻广告
要求:
打开页面,广告向上展开,点击“关闭”按钮,关闭广告
HTML和CSS代码片
:
// CSS 代码
<style type="text/css">
.adv{
width: 400px;
height: 300px;
background: url(../img/tx.jpg);
position: absolute;
bottom: -200px;
right: 0;
}
.adv>span{
position: absolute;
right: 0;
top: -12px;
font-size: 48px;
font-weight: 12px;
color: red;
}
</style>
// HTML 代码
<div style="position: fixed; bottom: 0; right: 0;">
<div id="adv" class="adv">
<span id="close">×</span>
</div>
</div>
JS代码片
:
<script type="text/javascript">
var myadv=document.getElementById("adv");
var myclose=document.getElementById("close");
var b=-300;
myclose.onclick=function(){
myadv.style.display="none";
}
function advUp(){
myadv.style.bottom=b+"px";
b+=10;
var timer=setTimeout("advUp()",100);
if(b>0){
clearTimeout(timer);
}
}
advUp()
</script>