说明:进入网站时广告窗缓慢显示出来 点击广告窗关闭按钮后 (x)广告窗缓慢消失;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
*{padding: 0px;margin: 0px;}
div{width: 300px;height: 350px;background: #999;position: absolute;right: 20px;bottom: 20px; opacity: 0;transition: all 2s ;}
p{height: 30px;background: red;}
.s2{float: right;line-height: 30px;color: #fff;width: 30px;height:30px;background: #333;text-align: center;font-size: 30px;opacity: 0.8;cursor:pointer;}
#s1{line-height: 30px;color: #fff;font-size: 18px;}
</style>
<script type="text/javascript">
window.onload=init;
function init() {
var o=document.querySelector('#ad');
//代码执行一次 再打开网站两秒后启动定时器
setTimeout(function(){
o.style.opacity=1;
},2000)
//点击关闭后广告窗透明度为0
document.querySelector('.s2').onclick=function () {