小广告效果

WEB前端学习交流群21 598399936

<!doctype html>

<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
*{
margin: 0;
padding: 0;
font-size: 14px;
box-sizing:border-box;
}
body{
background: url(http://joymepic.joyme.com/article/uploads/allimg/201511/1448602825502582.gif);
}
#ad{
height: 250px;
width: 350px;
border: solid 1px #aaa;
position: fixed;
right: 0;
bottom: -250px;
}
#close{
position: absolute;
right: 20px;
top: 10px;
cursor: pointer;
display: block;
height: 20px;
width: 20px;
text-align: center;
line-height: 20px;
background: #000;
color: #fff;
}
p:first-of-type{
width: 100%;
line-height: 40px;
height: 40px;
background: #0aa;
position: absolute;
top: 0;
left: 0;
padding-left: 20px;
}
p:first-of-type>span:first-of-type{
font-weight: bold;
}
textarea{
position: absolute;
left: 0;
top: 40px;
width: 350px;
height: 170px;
border: none;
}
p:last-of-type{
width: 100%;
line-height: 40px;
height: 40px;
background: #0aa;
position: absolute;
bottom: 0;
left: 0;
}
p:last-of-type>input{
position: absolute;
right: 20px;
top: 10px;
}
</style>
</head>
<body>
<div id="ad">
<p>
<span>请注意</span>
<span id="close">x</span>
</p>
<div>
<textarea></textarea>
</div>
<p>
<input type="submit">
</p>
</div>
<script type="text/javascript">
var oad = document.getElementById('ad');
var close = document.getElementById('close');
var timer1,timer2;
var count=-250;


// 弹出广告
function up(){
clearInterval(timer1);
timer1 = setInterval(function(){
count++;
oad["style"]["bottom"] = count+"px";
if(count == 0){
window.clearInterval(timer1);
}
},5);
}


function down() {
timer2 = setInterval(function(){
count--;
oad["style"]["bottom"] = count+"px";
if(count == -250){
clearInterval(timer2);
setTimeout(function(){
timer1 = setInterval(function(){
count++;
oad["style"]["bottom"] = count+"px";
if(count == 0){
window.clearInterval(timer1);
}
},5);
},3000);
}
},5);
}
window.onload = up;
close.onclick = down;




</script>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值