javascript实现右下角广告框效果
作者:Jack-小俊 时间:2024-04-17 10:25:08
本文教大家用原生js实现的简单网页主页右下角的广告框效果,利用好绝对定位,点击X关闭广告,里面的内容不管动图或者视频都可以。
代码最简洁,js行为优化版,复制粘贴即可使用。
演示部分
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>右下角广告框效果</title>
</head>
<style type="text/css">
#advbox{
width: 400px;
height: 300px;
position: fixed;
right: 0;
bottom: 0;
}
.adv{
width: 380px;
height: 270px;
border: 1px solid #a00;
position: relative;
}
#icon{
display: block;
width: 24px;
height: 24px;
color: #0c0;
font-size: 30px;
font-weight: bolder;
position: absolute;
right: 2px;
top: 2px;
cursor: pointer;
}
#resetadv{
width: 105px;
height:20px;
position: fixed;
right: 25px;
bottom: 15px;
color: #fff;
font-size: 20px;
background-color: #333;
}
.hide{
display: none;
}
.show{
display: block;
}
</style>
<body>
<div id="advbox">
<div class="adv">
<img src="" alt="结合html5,这可以是一个gif,swf或者video">
<span id="icon">X</span>
</div>
</div>
<div id="resetadv">广告入口>></div>
<script type="text/javascript">
(function(){
//封装一下dom的id操作
var $ = function(id){
return document.getElementById(id);
};
//添加点击事件
$("icon").onclick=function(){
$("advbox").className = "hide";
};
$("resetadv").onmouseover=function(){
$("advbox").className = "show";
};
})();
</script>
</body>
</html>
标签:js,广告框
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python3 配置logging日志类的操作
2021-04-22 20:15:09
![](https://img.aspxhome.com/file/2023/3/98853_0s.jpg)
浅谈flask截获所有访问及before/after_request修饰器
2023-08-21 10:05:59
vue-cli-service build 环境设置方式
2024-05-25 15:17:08
![](https://img.aspxhome.com/file/2023/8/123938_0s.png)
MYSQL实现连续签到功能断签一天从头开始(sql语句)
2024-01-22 16:35:11
![](https://img.aspxhome.com/file/2023/7/126257_0s.png)
vue实现选中效果
2024-05-11 09:12:56
Python使用UDP实现720p视频传输的操作
2023-12-04 09:32:49
![](https://img.aspxhome.com/file/2023/6/68836_0s.jpg)
SQL Server自动生成日期加数字的序列号
2024-01-12 21:29:42
如何使用 Go 和 Excelize 构建电子表格
2024-02-10 04:59:02
mysql数据库忘记管理员密码的解决方法
2024-01-24 10:56:55
python中合并两个文本文件并按照姓名首字母排序的例子
2023-05-28 17:41:32
深入浅析Python中的迭代器
2021-02-20 03:36:43
![](https://img.aspxhome.com/file/2023/1/134861_0s.png)
得到文本框选中的文字,动态插入文字的js代码
2024-05-03 15:31:03
在Sql Server中调用外部EXE执行程序引发的问题
2024-01-16 07:40:38
python3中TQDM库安装及使用详解
2023-02-17 20:05:55
![](https://img.aspxhome.com/file/2023/2/86322_0s.png)
用户体验杂谈
2011-10-21 21:09:08
phpstorm断点调试方法图文详解
2023-05-30 01:06:40
![](https://img.aspxhome.com/file/2023/9/55259_0s.jpg)
Python timer定时器两种常用方法解析
2023-07-21 19:20:56
Python selenium实现大麦网自动购票过程解析
2023-10-17 05:43:10
![](https://img.aspxhome.com/file/2023/8/114638_0s.gif)
JS打开新窗口的2种方式
2023-07-07 02:44:49
C#连接Oracle数据库的实例方法
2024-01-20 14:37:05